Php obtains the image in the folder path and the display by page. Copy the code as follows: div? Php $ pageisset ($ _ GET [page])? $ _ GET [page]: 0; starting from scratch $ img
The code is as follows:
$ Page = isset ($ _ GET ['Page'])? $ _ GET ['Page']: 0; // starts from scratch
$ Imgnums = 10; // Number of images displayed on each page
$ Path = "upload"; // saved Directory of the image
$ 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 )){
$ Array [] = $ file; // save the image name
++ $ I;
}
}
}
If ($ array ){
Rsort ($ array); // modify the descending order of dates
}
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 "homepage ";
Echo "previous page ";
Echo "next page ";
Echo "last page ";
}
?>
The http://www.bkjia.com/PHPjc/740204.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/740204.htmlTechArticle code is as follows: p style = "width: 90%; margin: 10px auto; border: 1px solid # ccc; text-align: center "? Php $ page = isset ($ _ GET ['Page'])? $ _ GET ['Page']: 0; // starts from scratch $ img...