can you loop through a equi-join query?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
sherdog
Forum Newbie
Posts: 1
Joined: Mon Aug 11, 2003 7:29 pm

can you loop through a equi-join query?

Post 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?
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post 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());
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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) ) {
Post Reply