$page=isset($_GET['page'])?$_GET['page']:0;//From Starting from zero
$imgnums = 10; //The number of pictures displayed on each page
$path="upload"; //The directory where the pictures are saved
$handle = opendir($path);
$ i=0;
while (false !== ($file = readdir($handle))) {
list($filesname,$ext)=explode(".",$file);
if($ext=="gif" or $ext=="jpg" or $ext=="JPG" or $ext=="GIF" ) {
if (!is_dir('./'.$file )) {
.
if($array){
rsort($array);//Sorted in reverse order by modified date
}
for($j=$imgnums*$page; $j<($imgnums*$ page+$imgnums)&&$j<$i; ++$j){ echo '
';
echo $array[$j],'
';
echo "
";
echo '
';
}
$realpage = @ceil($i / $imgnums) - 1;
$Prepage = $page-1;
$Nextpage = $page+1;
if($Prepage<0 ){
echo "Previous page";
echo "
Next page ";
echo "
Last page ";
}elseif($Nextpage >= $realpage){
" echo "
Homepage ";
echo "
Previous page ";
echo " Next page";
}else{
echo "< ;a href=?page=0>Homepage ";
echo "
Previous page ";
echo "< a href=?page=$Nextpage> 🎜> ?>