Page 1 of 1

can you loop through a equi-join query?

Posted: Mon Aug 11, 2003 7:29 pm
by sherdog
just curious if you can loop through a equi-join query?

my query is this
$status_query2 = "SELECT
c.fname, c.lname, c.b_email, c.cid, c.status, o.status, o.price, h.status,
b.status, h.billing_term, h.domain, b.payment_method o.tdate, o.status FROM
customer c, orders o, hosting_info h, billing b
WHERE c.status = 1 AND o.status = 1 AND b.status = 1 AND h.status = 1";
$result = mysql_query($status_query2);

and i want to loop through it to display the results in a table like

while( $myrow = mysql_fetch_array($result){
echo $myrow['fname'];
echo $myrow['lname'];
etc... ect....
}

I've tried and i get this error:

mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\ecg\SSL\orders_review.php on

any suggestions?

Posted: Tue Aug 12, 2003 2:35 pm
by xisle
looping through the join is definitely doable.
try doing some error checking before the fetch_array...

Code: Select all

$result=mysql_query($status_query2) or die(mysql_error());

Posted: Tue Aug 12, 2003 2:38 pm
by JAM
Sherdog:
If you are copy-n'-pasting your code directly, you have an error...

Code: Select all

//yours:
while( $myrow = mysql_fetch_array($result){ 

//right:
while( $myrow = mysql_fetch_array($result) ) {