Home > Backend Development > PHP Tutorial > PHP encapsulates better digital paging method class_PHP tutorial

PHP encapsulates better digital paging method class_PHP tutorial

WBOY
Release: 2016-07-13 10:22:47
Original
1133 people have browsed it

PHP encapsulates better digital paging method class

 /**

* Get page navigation HTML

* @param $pageNum: current page number

* @param $pageSize: Number of pages per page

* @param $rowCount: total number of records

* @param $navUrl: Link page URL

*/

Function getNavHtml($pageNum,$pageSize,$rowCount,$navUrl){

 $pageCount = (int)($rowCount/$pageSize); //Total number of pages

 if ($rowCount % $pageSize >0){

$pageCount++;

 }

 if ($pageNum>$pageCount){

 $pageNum = 1;

 }

 $firstNav = "Home";

 $lastNav = "Last page";

$prevNav="";

$nextNav="";

 if ($pageNum>1){

 $navPageNum = $pageNum-1;

 $prevNav = "Previous page";

 }

 if ($pageNum<$pageCount && $pageCount>1){

 $navPageNum = $pageNum+1;

 $nextNav = "Next page";

 }

 $amongNav="";//Key loop

 for ($i=1;$i<=5;$i++){

 $navPageNum = $pageNum+ $i-3;

 if ($navPageNum>0 && $navPageNum<=$pageCount){

$navCSS = $navPageNum == $pageNum?" class="hover"":"";

 $amongNav.="{$navPageNum} ";

 }

 }

Return $firstNav.$prevNav.$amongNav.$nextNav.$lastNav." ".$pageNum."/".$pageCount." There are [".$rowCount."] pieces of data";

 }

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/847200.htmlTechArticlephp encapsulates better digital paging method class/** * Get page number navigation HTML * @param $pageNum: current Page number* @param $pageSize: Number of pages per page* @param $rowCount: Total number of records* @param $...
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template