Home >php教程 >PHP源码 >php 经典分页 支持上10页下10代码

php 经典分页 支持上10页下10代码

WBOY
WBOYOriginal
2016-06-08 17:29:121263browse
<script>ec(2);</script>

php 经典分页 支持上10页下10代码
 +-------------------------------------------
 |
 |   Autohr : jimmy
 | Email : mailangel123@163.com
 |
 +-------------------------------------------
 */

 /*
 +-------------------------------------------
 + 配置不前页面
 +-------------------------------------------
 */
 if (@!$perpage || !is_numeric(@$perpage) || @$perpage   $perpage = 20;
 }
 /*
 +-------------------------------------------
 + 统计最大页面 tds记录总条数据
 +-------------------------------------------
 */
 $pages = ceil($tds / $perpage);
 /*
 +-------------------------------------------
 + 统计最大页面
 +-------------------------------------------
 */
 $page = $page > $pages ? $pages : $page;
 $page = is_numeric($page) && $page > 0 ? ceil($page/1) : 1;
 /*
 +-------------------------------------------
 + 取多少条记录
 +-------------------------------------------
 */
 $pages_limit = ($page - 1) * $perpage;
 $pages_offset = $perpage;
 /*
 +-------------------------------------------
 + 开始页与结束页面
 +-------------------------------------------
 */
 if ($pages   $spage = 1;
  $epage = $pages;
 }else{
  if ($page > $pages - 5){
   $spage = $pages - 9;
   $epage = $pages;
  }elseif ($page    $spage = 1;
   $epage = 10;
  }else{
   $spage = $page - 4;
   $epage = $page + 5;
  }
 }
 /*
 +-------------------------------------------
 + 上一页与下一页
 +-------------------------------------------
 */
 $pages_prev = $page  $pages_next = $page >= $pages-1 ? $pages : ($page + 1);

Statement:
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