help w/Multiple Joins

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux