say theres a listing of files in a directory, and you want to list 12 files per page...
I got the files to display and the amount of files in the dir.
What I dont understand how to do is split the total amount of files to output 12 file links per page, and then the next 12 on the second page etc... (assuming the system sorts by filename in ascending order)
thanks,
Code:
if ($handle = opendir('./dir')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<a href=\"$file\">$file</a><br>" ;
}
$totalfiles += count($file);
}
closedir($handle);
}
Code:
$filesperpage = 12;
//rounds off to higher value so remainder is shown
$totalpages = ceil($totalfiles/$filesperpage);
echo $totalpages . ' ';
// prints page links...
for($j = 1; $j <= $totalpages; )
{print "<a href=\"$j\">" . $j++ . ' </a>'; }
What I dont understand how to do is split the total amount of files to output 12 file links per page, and then the next 12 on the second page etc... (assuming the system sorts by filename in ascending order)
thanks,