I have a image gallery where I am calling up on the script to display 3 images in a row using <td> tags to help organize.
My problem is figuring out how to include the closing </tr> tag. If the row displays 3 images, it closes with the appropriate tag, but if there is less then 3 images in that row, then the closing </tr> tag doesn't work.
Not quite sure what I'm doing wrong with it. Any help in the right direction would be great.
I was thinking maybe I need to add a way to create empty <td> in case there was only 16 images for example and only 5 rows would show correctly with a 6th row only having one image in it.
Suggestions?
$i=0;
foreach ($gallery_array as $row)
{
if ($i%3==0) // open row
{
echo"<tr>\n";
}
$image = $row["gallery_image"];
echo "<td><img src=\"".$image."\"></td>\n";
$i++;
if ($i%3==0) // close row, only working if 3 images in a row, is not closing if less then 3 images
{
echo"</tr>\n";
}
}