This article mainly describes the PHP to get the folder path in the picture and pagination display examples, the need for friends can refer to the following
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;//from zero-start & nbsp $imgnums = 10; //The number of pictures per page $path = "Upload"; //Picture saved directory $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") { &NB Sp if (!is_dir ('./'. $file)) { $array []= $file;//Save picture name &N Bsp + + $i; } if ($array) {& nbsp rsort ($array);//Modify date reverse order } for ($j = $imgnums * $page; $j < ($imgnums * $page + $imgnums) && $j < $i; + + $j) { echo ' <div> '; echo $array [$j], ' <br/> '; &N Bsp echo "<img src=". $path. " /". $array [$j]." ><br/> "; echo ' </div> '; } $realpage = @ceil ($i/$imgnums)-1; $Prepage = $page-1; $Nextpage = $page +1; if ($Prepage <0) { echo "prev"; echo "<a href=?page= $Nextpage > next page </a>"; echo "<a href=?page= $realpage > last page </a>"; }elseif ($Nextpage >= $realpage) { echo "<a href=?page=0> home </a>"; echo "<a href=?page= $Prepage > Prev </a>"; echo "next page"; }else{ echo "<a href=?page=0> home </a>"; echo "<a href=?page= $Prepage > Prev </a>"; echo "<a href=?page= $Nextpage > next page </a>"; echo "<a href=?page= $realpage > last page </a>"; } ?> </div>