首页 > 代码库 > php分页

php分页

1.总记录数

每页条数

当前页

总页数

$_count     = $people_num; //总记录数
$pagesize = 1;//每页条数
$page = empty($_REQUEST[‘page‘]) ? 1 : intval($_REQUEST[‘page‘]);//当前页
$total_page = ceil($_count/$pagesize);//总页数

2.实例化分页类

Vendor(‘MyClass.Page‘);
$PagePaper = new Pagediv($_count, $pagesize, $total_page, $page, ‘getLists‘);

3.
if($total_page >= 1) {
$showPaper = $PagePaper->show();
}
if($page <= $total_page) $start = ($page-1)*$pagesize;

4.sql语句,$start,$pagesize

5.
$info[‘**‘] = $showPaper;
$info[‘**‘] = $_count;
$info[‘**‘] = ceil($_count/$pagesize);
$info[‘**‘] = $page;

6.模板和js

php分页