Be sure the files are 'img' type
set $workDir
This displays in one column
use HTML and CSS for more columms
PHP Code:
<?php
// program => test_pagination.php <=
$exclude_files = array("");
$ifiles = Array();
$number_to_display = '10';
$workDir = 'test';
if(!$_GET['start'])
{
$start = 0;
}
else
{
$start = $_GET['start'];
}
$handle = opendir($workDir);
while (FALSE !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && !in_array($file, $exclude_files))
{
// replace space in file name with "%20" else 'src = ' will stop at first
// space for file name
$file = str_ireplace(" ", "%20", $file);
$ifiles[] = $file;
}
}
closedir($handle);
$total_files = count($ifiles);
$req_pages = ceil($total_files/$number_to_display);
print "Total files = ". $total_files."<br>\n";
print "$req_pages pages at $number_to_display max per page<br>\n";
print "Start at #" . ($start + 1) . "<br>\n";
$temp = $start + $number_to_display;
if ($temp > $total_files)
{
$next_number_to_display = $total_files - $start;
}
else
{
$next_number_to_display = $number_to_display;
}
print "Number to show = " . $next_number_to_display . "<br>\n";
for($z=0; $z<$next_number_to_display; $z++)
{
$vf = $z+$start;
print "<img width=100 height=100 src = $workDir/$ifiles[$vf]>" . ($vf + 1) . "</img><br>\n<br>\n";
}
print "<a href=\"?start=0\">First start 1</a> | \n";
for($x=1; $x < $req_pages - 1; $x++)
{
$temp = $x * $number_to_display;
print "<a href=\"?start=$temp\">Next $number_to_display start at " . ($temp + 1) . "</a> | \n";
}
$temp = $temp + $number_to_display;
$y = $total_files - ($x * $number_to_display);
print "<a href=\"?start=$temp\">Last $y start at " . ($temp + 1) . "</a>";
?>