Thanks
Code: Select all
<table width="70%" align="center" cellpadding="0" cellspacing="0" border="0">
<?php
$gall_array = array();
$g = 0; //Counter for num folders
$handle = opendir('gallery'); //Where pics are stored
while ($file = readdir($handle)) {
if (is_dir('gallery/'.$file) && $file != '..' && $file != '.') {
$gall_arrayї$g] = $file; //Keep a record of the folders
$g++; //Count gallery folders
}
}
$gallerycount = $g;
//Using a table with 3 cells per row
$gall_rows = ceil($gallerycount/3);
$count = 0;
for ($i=0; $i<$gall_rows; $i++) { //This only does one loop
echo "\t".'<tr>'."\r\n";
for ($i = $count; $i < ($count+3); $i++) {
if ($i < count($gall_array)) {
echo "\t\t".'<td>'."\r\n";
echo "\t\t\t".'<table cellspacing="0" cellpadding="0" border="0" class="norm" style="float:
left">'."\r\n";
echo "\t\t\t\t".'<tr>'."\r\n";
echo "\t\t\t\t\t".'<td width="170" height="170" align="center" valign="middle" background="
img/frame.gif"><img src="gallery/'.$gall_arrayї$i].'/thumb.jpg"></td>'."\r\n";
echo "\t\t\t\t".'</tr>'."\r\n";
echo "\t\t\t\t".'<tr>'."\r\n";
echo "\t\t\t\t\t".'<td><b>'.$gall_arrayї$i].'</td>'."\r\n";
echo "\t\t\t\t".'</tr>'."\r\n";
echo "\t\t\t".'</table>'."\r\n";
echo "\t\t".'</td>'."\r\n";
} else {
echo "\t\t".'<td>'."\r\n";
echo "\t\t\t".'<table cellspacing="0" cellpadding="0" border="0" class="norm" style="float:
left">'."\r\n";
echo "\t\t\t\t".'<tr>'."\r\n";
echo "\t\t\t\t\t".'<td width="170" height="170" align="center" valign="middle"> </td>'
."\r\n";
echo "\t\t\t\t".'</tr>'."\r\n";
echo "\t\t\t\t".'<tr>'."\r\n";
echo "\t\t\t\t\t".'<td> </td>'."\r\n";
echo "\t\t\t\t".'</tr>'."\r\n";
echo "\t\t\t".'</table>'."\r\n";
echo "\t\t".'</td>'."\r\n";
}
}
//$count += 3;
echo "\t".'</tr>'."\r\n";
}
?>
</table>