Forum Moderators: coopster
I can not set the gallery displaying the thumbs by rows of 3
For example in my test I have 6 uploaded images and the result is
Img img empty-space
Img img img
Img empty-space empty-space
So the six pics are there but not organized as supposed by rows of three
if it was 7 pics then it should be 2 rows of 3 plus 1 row: img empty-space empty-space
Here is what I have:
while( $row = mysql_fetch_array( $result ) )
{
$result_array[] = "<a href='all_gal/$main_gal/".$row['img_filename']." '><img src='".$img_gal."/tb_".$row['img_filename']."'
border='0' alt='".$row['img_caption']."' /></a>";
}
mysql_free_result( $result );$thumb_per_row =3;
$show = "<tr>\n";
$counter = 1;
foreach($result_array as $thumbnail_link)
{
if($counter == $thumb_per_row)
{
$counter=1;
$show .= "\n</tr>\n<tr>\n";
}
else
$counter++;$show .= "\t<td align='center'>".$thumbnail_link."</td>\n";
}if($counter)
{
if($thumb_per_row-$counter)
$show .= "\t<td align='center' colspan='".($thumb_per_row-$counter)."'> </td>\n";$show .= "</tr>";
}
}
i usually go the css way in these matters
<style type="text/css">
#gallery { border: solid 0px #115; margin: 1em; padding: 0.5em; }
#gallery ul { display: block; margin: 0px; padding: 0px;}
#gallery li { display: block; list-style: none; float: left; margin: 0.25em; padding: 0px; border: solid 1px #111155; background: #ffffff; }
#gallery li p { text-align: center; margin: 0px; padding: 0.5em;}
#gallery hr { clear: both; visibility: hidden; margin: 0px; padding: 0px; height: 1px; }
</style>
and for the showing images:
<div id="gallery">
<ul>
// loop to showimages
<li>show image</li>
</ul>
<hr>
</div>
put this into a table with specific width. If for example your thumbs are 150px width, put the above in a table 500px width and you are set.
i think its easier this way
while( $row = mysql_fetch_array( $result ) )
{
$result_array[] = "<a href='all_gal/$main_gal/".$row['img_filename']." '><img src='".$img_gal."/tb_".$row['img_filename']."'
border='0' alt='".$row['img_caption']."' /></a>";
}
mysql_free_result( $result );$thumb_per_row =3;
$show = "<tr>\n";
$counter = 0;
foreach($result_array as $thumbnail_link)
{
if($counter == $thumb_per_row)
{
$counter=1;
$show .= "\n</tr>\n<tr>\n";
}
else
$counter++;$show .= "<td align='center'>".$thumbnail_link."</td>\n";
}if($counter)
{
if($thumb_per_row-$counter)
$show .= "<td align='center' colspan='".($thumb_per_row-$counter)."'> </td>\n";$show .= "</tr>";
}
}
When I will be totally done with that segment I will post it well documented.