I've been trying to get links to display in rows of six columns with the following code:
<?php
$max_cols = 6;
$fileCount = 0;
$output = '';
$fileCount++;
$dir = "pictures";
$folder = scandir($dir, 0);
$files = array_reverse($folder);
for( $ctr = 0; $ctr < sizeof( $files ); $ctr++ ) {
if($files[$ctr] != "." && $files[$ctr] != "..")
if (sscanf($files[$ctr], '%4d%2d%2d', $year, $month, $day) == 3) {
$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December');
$date = "$day $months[$month] $year";
if($fileCount%$max_cols==1)
{
$output .= "<tr>\n";
}
$output .= "<td align=center><a href='list_pictures.php?pics=$dir/$files[$ctr]'>$date</a></td>";
if($fileCount%$max_cols==0)
{
$output .= "</tr>\n";
}
if($fileCount%$max_cols!=0)
{
$output .= "</tr>\n";
}
print "
<table width=38% height=\"115\" border=\"0\" cellpadding=\"\"0 cellspacing=\"4\" bgcolor=\"#000000\">
{$output}
</table>
";
}
}
?>
I've tried to adapt code I've used successfully elsewhere, but for some reason it's not displaying how I want, rather in a single column.
Can anyone help me out of the gloom!?
Many thanks,
Rupert