Warning: I know enough PHP to get by, but not enough to do it efficiently. And I am lost as to how to do this...
I am creating a PHP Photo Album script - the actual photo is stored in the file structure with the info in a mySQL Database. My problem is creating a catalog to view the photos as thumbnails. I can get the thumbnails to display with no problem, but I am having trouble creating the html table to put the thumbnails in - because the exact number of photos changes with each category - and I am clueless as to how to make a table with the correct <tr> and </tr> tags with "colspan="?" on the last <tr>...
Here is my code and how I was going about it...thanks in advance for any help and suggestions.
include "album_config.inc.php";
// Number of thumbnails in a row
$thumbrow = 5;
if ($category_id)
{
$countresult = mysql_query("SELECT COUNT(photoID) as photocount FROM photo WHERE category=$category_id ORDER BY photoID");
$countrow = mysql_fetch_array($countresult);
$newcount = $countrow["photocount"];
$counter = 1;
echo "<table>\n";
$result = mysql_query("SELECT * FROM photo WHERE category=$category_id ORDER BY photoID");
while ($myrow = mysql_fetch_array($result))
{
$photoID = $myrow['photoID'];
$photoFileName = $myrow['photoFileName'];
$title = $myrow['title'];
if ($counter == $thumbrow)
{
// Here is where I am starting to get lost
$counter = 1;
echo "</tr>\n";
}
else
{
if ($counter == 1)
{
// I am really starting to get lost
echo "<tr>\n";
}
echo "<td><div class=\"album\"><a href='viewphoto.php?photoID=$photoID'><img src='/gallery/thumbnail.php?image=".IMAGE_PATH."/$photoFileName'/></a><br /><p>$title</p></div></td>\n";
if ($newcount > 5)
{
// I am completely lost! Help!
}
$counter++;
}
}
echo "</table>\n";
}