im printing a listing of all files in a folder using a simple script.
however I dont want it to be all in one single column, thus im making a table.
5 items <---> (width)
and as many colums as needed (5x?)
thats my code:
I need to make it look something similar to:
basically i need it to print </tr><td> every 5 items echo'd so it creates another line in the table. so I set a var $x and add 1 to it everytime an item is echo'd and when its at 5, make it output the </tr><td> and reset $x to 0
however I dont want it to be all in one single column, thus im making a table.
5 items <---> (width)
and as many colums as needed (5x?)
thats my code:
PHP:
<?
$maindir = "." ;
$mydir = opendir($maindir) ;
$exclude = array( "index.php" , ".", "..") ;
?>
<div align="center">
<center>
<table border="0" width="440" cellspacing="0" cellpadding="0">
<tr>
<?
while($fn = readdir($mydir))
{ if ($fn == $exclude[0] || $fn == $exclude[1] || $fn == $exclude[2]) continue;
echo "<td width=\"20%\" align=\"center\"><img src=\"$fn\"></td>"; }
closedir($mydir);
?>
</tr>
</table>
</center>
</div>
I need to make it look something similar to:
PHP:
<?
while($fn = readdir($mydir))
{ if ($fn == $exclude[0] || $fn == $exclude[1] || $fn == $exclude[2]) continue;
(if $x = 5 then echo "</tr><td>" and $x=0);
echo "<td width=\"20%\" align=\"center\"><img src=\"$fn\"></td>";
$x=$x+1;}
closedir($mydir);
?>
basically i need it to print </tr><td> every 5 items echo'd so it creates another line in the table. so I set a var $x and add 1 to it everytime an item is echo'd and when its at 5, make it output the </tr><td> and reset $x to 0