comparing problem

This is a discussion on comparing problem within the alt.comp.lang.php forums, part of the PHP Programming Forums category; The problem is like this, There are a number of $rows resulting from the query described below. There is a ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-28-2005
Irlan agous
 
Posts: n/a
Default comparing problem


The problem is like this, There are a number of $rows resulting from the
query described below. There is a variable named payment, this has for
example the vualue 2. lets say the query had 5 results, the i want to do a
compare that it shows only 2, depending on the value of $payment

Can someone help me?

$query = "SELECT a.oproep,b.oproep, a.react, b.react, a.logid, b.logid,
a.persid,b.persid, a.logemail, b.logemail,a.persemail,b.persemail

FROM reactie a, reactie b
WHERE a.logid = b.persid AND b.logid = a.persid AND a.logid='$logid' ";


$result = mysql_query($query);

$query_data = mysql_fetch_row($result);// Haal de gegevens uit de tabel
if($result = mysql_query($query)){
$rows = mysql_num_rows($result);

if($rows<1){
echo "<p>You have no Matches";

} else {


echo "<p>You have $rows Match(es)<p><p>";
}}
while($query_data = mysql_fetch_array($result)){


$oproep = $query_data["oproep"];
$persid = $query_data["logid"];
$reactie = $query_data["react"];
$logemail = $query_data["logemail"];

echo " <tr>\n";
echo " <td align=center bgcolor=FFECC4 ><font
color=black><a
href=\"javascript:Pop550Picture('../pic/klanten/gegevens.php?id=$persid')\"><p>$oproep</a></td>\n";//

echo " <td align=center bgcolor=FFECC4 ><font
color=black><p>".$reactie."</td>\n";
echo " <td align=center bgcolor=FFECC4 ><font
color=black><p>".$reactie."</td>\n";
echo " <td align=center bgcolor=FFECC4 ><font
color=black><p><a href=\"mailto:".$logemail."\">".$logemail."</a></td>\n";


echo " </tr>\n";//

}


Reply With Quote
  #2 (permalink)  
Old 03-28-2005
Oli Filth
 
Posts: n/a
Default Re: comparing problem

Irlan agous wrote:
> The problem is like this, There are a number of $rows resulting from the
> query described below. There is a variable named payment, this has for
> example the vualue 2. lets say the query had 5 results, the i want to do a
> compare that it shows only 2, depending on the value of $payment
>
> Can someone help me?
>


Do you mean you only want to show the 2nd result? In which case add
"LIMIT 1, 1" to the end of your SELECT query.

Or do you mean you only want to show 2 results? In which case add "LIMIT
2" to the end of your SELECT query.

"SELECT ... LIMIT n"
returns only the first n results found.

"SELECT ... LIMIT x, n"
returns n results starting from the x-th row (first row is x=0).


--
Oli
Reply With Quote
  #3 (permalink)  
Old 03-28-2005
Irlan agous
 
Posts: n/a
Default Re: comparing problem

Thanks for your answer, i mean the last one, but the 2 results are read from
the variable $payment, so can i do something like this?

"SELECT ... LIMIT 0, $payment"

Thanks

"Oli Filth" <catch@olifilth.co.uk> schreef in bericht
news:x_S1e.168$Sw.73@newsfe2-gui.ntli.net...
> Irlan agous wrote:
>> The problem is like this, There are a number of $rows resulting from the
>> query described below. There is a variable named payment, this has for
>> example the vualue 2. lets say the query had 5 results, the i want to do
>> a compare that it shows only 2, depending on the value of $payment
>>
>> Can someone help me?
>>

>
> Do you mean you only want to show the 2nd result? In which case add "LIMIT
> 1, 1" to the end of your SELECT query.
>
> Or do you mean you only want to show 2 results? In which case add "LIMIT
> 2" to the end of your SELECT query.
>
> "SELECT ... LIMIT n"
> returns only the first n results found.
>
> "SELECT ... LIMIT x, n"
> returns n results starting from the x-th row (first row is x=0).
>
>
> --
> Oli



Reply With Quote
  #4 (permalink)  
Old 03-28-2005
Oli Filth
 
Posts: n/a
Default Re: comparing problem

Irlan agous wrote:
> Thanks for your answer, i mean the last one, but the 2 results are read from
> the variable $payment, so can i do something like this?
>
> "SELECT ... LIMIT 0, $payment"
>


Yes, as long as you use double-quotes. See
http://www.php.net/manual/language.types.string.php for different ways
of getting variables into strings.


--
Oli
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:01 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0