This code will loop all the images inside "images" folder and display them. For every 7 images, a new row is added.
<table>
<tr>
<?php
$photo_dir = "images";
$files = glob($photo_dir."/*.*");
for ($i=0; $i<count($files); $i++)
{
$j = $i+1;
?>
<td height="25" align="center">
<?php
$num = $files[$i];
$img_name = explode(".", basename($num));
echo '<a href="'.$num.'">
<img src="'.$num.'" width="120" height="120" style="border:4px solid #FFF;"></a>'; // .$img_name[0];
?>
</td>
<?php
if($j % 7 == 0)
echo '</tr><tr>';
}
?>
</tr>
</table>
<table>
<tr>
<?php
$photo_dir = "images";
$files = glob($photo_dir."/*.*");
for ($i=0; $i<count($files); $i++)
{
$j = $i+1;
?>
<td height="25" align="center">
<?php
$num = $files[$i];
$img_name = explode(".", basename($num));
echo '<a href="'.$num.'">
<img src="'.$num.'" width="120" height="120" style="border:4px solid #FFF;"></a>'; // .$img_name[0];
?>
</td>
<?php
if($j % 7 == 0)
echo '</tr><tr>';
}
?>
</tr>
</table>
Nice Tutorial .. Thank You !
ReplyDelete