Good try. You forgot it was an if-else situation:
IF less than 5 images on row, add to row
ELSE start new row first, then show the current image
echo '<table align="left" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>';
$sql = "SELECT *
FROM images WHERE showID = $showID";
$res = mysql_query($sql);
$i = 0;
while($image = mysql_fetch_array($res)) {
if($i < 5){
// if less than 5 images in row, show another
echo '<td><a href="imageDisplay.php?id="'.$image['id'].'" target="display"><img src="'.$image['location'].'"/thumbs"'.$image['pic'].'.'.$image['ext'].'" width="55" height="45" border="0"></a></td>';
}
else {
// otherwise start a new row
echo '</tr><tr>';
// reset counter
$i=0;
// show first image
echo '<td><a href="imageDisplay.php?id="'.$image['id'].'" target="display"><img src="'.$image['location'].'"/thumbs"'.$image['pic'].'.'.$image['ext'].'" width="55" height="45" border="0"></a></td>';
} //-- endif
// count the image, whether it was a new row or not you count it, so you count it outside the if-else
$i++;
} //-- wend
echo '</tr></table>';
Now, as my sig says, there could be typos, BUT THERE IS NO LOGIC ERROR
Also:
no need for brackets with the echo
notice my string quoting syntax
since SQL uses single quotes in queries, I use double quotes aroung SQL in my PHP
since HTML uses double quotes in it's syntax, I use single quotes around it in PHP
Just makes it easier to keep it clean