I have a page of images for my users to select one for editing. The following code shows these images in two columns with their captions alongside each image. Unfortunately, the first column of captions expands to take the caption on one line and squeezes the others into a small column.
Is there a way to display the images in two columns withe their captions underneath each one.
$SQL = "SELECT photo_id, photo_thumbnail, photo_caption FROM gallery_photos WHERE photo_category='$category' ORDER by upload_date DESC";
// execute SQL statement
$ret = mysql_db_query($dbname,$SQL,$link);
$numrows = mysql_num_rows($ret);
if (!$ret) { echo( mysql_error()); }
else {
$col=0;
echo '<table width="500" border="1" cellspacing="1" cellpadding="2" align="center">';
//echo '<table>';
while ($img = mysql_fetch_array($ret)) {
$photo_id = $img[photo_id];
$thumbnail = $img[photo_thumbnail];
$caption = $img[photo_caption];
if($col==0) echo '<tr>';
echo "<td><img src=\"$thumbnail\"></td>";
echo "<td><a href=\"modify_photo.php?photo_id=$photo_id\">$caption</td>";
$col++;
if ($col==2){
echo '</tr>';
$col=0; }
}
}
if($col!=0) str_repeat('<td></td>', 2 - $col);
echo '</table>';
(Changed [noparse]
tags to [code=php] tags[/noparse]. -- NogDog)[/i]