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);