help w/Multiple Joins

From: Date: Wed, 20 Nov 2002 22:10:17 +0000
Subject: help w/Multiple Joins
Groups: php.db 
Request: Send a blank email to php-db+get-23540@lists.php.net to get a copy of this message
Hello, I'm trying to put together a little photo album section for a website. I have this query which returns the expected info from the command line. SELECT * FROM photo_album as p INNER JOIN images AS i1 ON p.img_1=i1.img_id INNER JOIN images AS i2 ON p.img_2=i2.img_id INNER JOIN images AS i3 ON p.img_3=i3.img_id INNER JOIN images AS i4 ON p.img_4=i4.img_id; The problem is when i try to display this on a page. Here is what i have <?php include "includes/connect.php"; $result = mysql_query("SELECT * FROM photo_album as p INNER JOIN images AS i1 ON p.img_1=i1.img_id
       INNER JOIN images AS i2 ON p.img_2=i2.img_id
       INNER JOIN images AS i3 ON p.img_3=i3.img_id
       INNER JOIN images AS i4 ON p.img_4=i4.img_id",$db)or die(mysql_error());
if ($myrow = mysql_fetch_array($result)) {
     do {
print "<table> <tr> <td<img src=$myrow[img_path]></td> </tr> </table>";
     } while ($myrow = mysql_fetch_array($result));
} ?> This displays only the last inner join image not four like i was expecting. How can i pull all the images from the array? I've tried lots of different ways like <img src=$myrow[i3.img_path]> with no luck. Any help would be greatly appreciated. Thanks in advance, Mike

« previous php.db (#23540) next »