I'm putting together a simple image gallery, but I can't figure out how to get it to display ALL the images with a specific CatID. This is what I've pieced together, but it just keeps repeating the same image.
<?php
$CatID = $_REQUEST['CatID'];
$Photos = mysql_query("SELECT ID, Title, ImageURL, CatID, Details FROM Photo WHERE CatID='$CatID'", $connection) or die("error querying database");
$rows_nb = mysql_num_rows($Photos);
$pic_num = 0;
$pic_code = mysql_fetch_array($Photos);
echo '<table width="75%" border="0" align="center">';
while($row = mysql_fetch_assoc($Photos))
{
echo '<tr>';
for ($tb_rows=0;$tb_rows<3;$tb_rows++)
{
if ($pic_num < $rows_nb)
{
echo '<td><div align="center"><img src="'.$pic_code['ImageURL'] .'" border="1" /></div></td>';
$pic_num++;
}else{
echo '<td></td>';
}
}
echo '</tr>';
}
echo '</table>';
?>