I've been working with the following code and would like to output the results into a customizable column variable, how would I go about doing such a thing, thanks in advance for any help. I hard coded the columns in the code below, but I would like the variable to be set so that a new row will start after a set number of columns.
Code:
<?
$allfiles = scandir('.');
$goodfiles = array();
foreach($allfiles as $f){
if(strpos($f,'.')!==0){
array_push($goodfiles,$f);
}
}
$pages = array_chunk($goodfiles, 10);
$columns = 2;
$pgkey = (int)$_GET['showpage']; // forces $_GET['showpage'] to be an integer
$pages[$pgkey];
echo "<table border='0' cellpading='2' cellspacing='2' align='center'><tr>";
foreach($pages[$pgkey-1] as $file){ echo '<td align=center><img src=files/'.$file.'></td>';
}
echo "</tr></table>";
?>
<? for($i=1; $i< count($pages)+1; $i++): ?>
<a href="index.php?showpage=<? echo $i;?>"><? echo $i; ?></a>
<?
endfor;
?>
Comment