For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > March 2005 > Matching problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Matching problem
Irlan agous

2005-03-28, 8:56 am

Hello all, i have this matching story. What i want to do, is to check the
variable $betaling if this is 0 or 1. But the id from the tabel form have to
be compared with $persid from the table reactie. thats not the problem, the
problem is i am not able to make 2 queries in one while statement, does
anyone knows how to solve this?

Irlan


$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);//

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"];


$sql= "SELECT betaling from form where id='$persid'";
$res = mysql_query($sql);
$query_data = mysql_fetch_row($res);
while($query_data = mysql_fetch_array($result)){
$betaling= $query_data["betaling"]

}
if ($betaling="0"){
echo "your contact did not pay for this service yet, he will be notified,
you dont have to pay for this service";
} else {

echo " <tr>\n";
echo " <td align=center bgcolor=FFECC4 ><font
color=black><a
href=\"java script: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";//

}}


NC

2005-03-28, 3:57 pm

Irlan agous wrote:
>
> What i want to do, is to check the variable $betaling if this
> is 0 or 1. But the id from the tabel form have to be compared
> with $persid from the table reactie. thats not the problem,
> the problem is i am not able to make 2 queries in one while
> statement


You don't have to. Everything you are trying to do can be
done in one query, something like this:

$query = <<<EOQ

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,
c.betaling
FROM
(reactie AS a LEFT JOIN reactie AS b ON a.logid = b.persid)
LEFT JOIN form AS c ON a.logid = c.id
WHERE
a.logid='$logid' AND b.logid = a.persid

EOQ;

Obviously, this query may not be exactly what you need because
you didn't explain what you wanted, but the general idea is
to join `form` to the two instances of `reactie` instead of
making the second query...

Cheers,
NC

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com