Home > Backend Development > PHP Tutorial > Example of php getting the pictures in the folder path and paging display_PHP tutorial

Example of php getting the pictures in the folder path and paging display_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:36:13
Original
1575 people have browsed it

Copy code The code is as follows:


$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> 🎜> ?>







http://www.bkjia.com/PHPjc/740204.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/740204.html

Copy the code as follows: div style="width: 90%; margin: 10px auto; border: 1px solid # ccc; text-align: center" ?php $page=isset($_GET['page'])?$_GET['page']:0;//Start from scratch $img...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template