Home > php教程 > php手册 > php封装较好的数字分页方法类

php封装较好的数字分页方法类

WBOY
Release: 2016-06-13 09:28:47
Original
1010 people have browsed it

php封装较好的数字分页方法类

   /**

  * 获取页码导航HTML

  * @param $pageNum:当前页码

  * @param $pageSize:每页数量

  * @param $rowCount:记录总数

  * @param $navUrl:链接页面URL

  */

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

  $pageCount = (int)($rowCount/$pageSize); //总页数

  if ($rowCount % $pageSize >0){

  $pageCount++;

  }

  if ($pageNum>$pageCount){

  $pageNum = 1;

  }

  $firstNav = "首页 ";

  $lastNav = "尾页 ";

  $prevNav="";

  $nextNav="";

  if ($pageNum>1){

  $navPageNum = $pageNum-1;

  $prevNav = "上一页 ";

  }

  if ($pageNum1){

  $navPageNum = $pageNum+1;

  $nextNav = "下一页 ";

  }

  $amongNav="";//关键循环

  for ($i=1;$i

  $navPageNum = $pageNum+ $i-3;

  if ($navPageNum>0 && $navPageNum

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

  $amongNav.="{$navPageNum} ";

  }

  }

  return $firstNav.$prevNav.$amongNav.$nextNav.$lastNav." ".$pageNum."/".$pageCount." 共有[".$rowCount."]条数据";

  }

  }

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template