php简单分页类
来源:未知 责任编辑:责任编辑 发表时间:2015-10-08 14:15 点击:次
<?php
/**
* 分页类
* 2011/8/31
* kcj
* */
class Page{
private $total; //查询总的数据记录
private $page; //当前第几页
//private $pagesize; //每页显示的条数
private $pagenum; //总共多少页
private $num; //每页显示记录的条数
private $offset; //从数据库中取记录的开始偏移数
function __construct($total,$page=1,$num=5){
$this->total=$total;
$this->page=$page;
$this->num=$num;
$this->pagenum=$this->getPageNum();
$this->offset=$this->getOffset();
}
private function getPageNum(){
return ceil($this->total/$this->num);
}
private function getNextPage(){ //下一页
if($this->page==$this->pagenum){
return false;
}else {
return $this->page+1;
}
}
private function getPrevPage(){
if($this->page==1){ //上一页
return false;
}else {
return $this->page-1;
}
}
private function getOffset(){
return ($this->page-1)*$this->num;
}
private function getStartNum(){
if ($this->total==0) {
return 0;
}else {
/**
* 分页类
* 2011/8/31
* kcj
* */
class Page{
private $total; //查询总的数据记录
private $page; //当前第几页
//private $pagesize; //每页显示的条数
private $pagenum; //总共多少页
private $num; //每页显示记录的条数
private $offset; //从数据库中取记录的开始偏移数
function __construct($total,$page=1,$num=5){
$this->total=$total;
$this->page=$page;
$this->num=$num;
$this->pagenum=$this->getPageNum();
$this->offset=$this->getOffset();
}
private function getPageNum(){
return ceil($this->total/$this->num);
}
private function getNextPage(){ //下一页
if($this->page==$this->pagenum){
return false;
}else {
return $this->page+1;
}
}
private function getPrevPage(){
if($this->page==1){ //上一页
return false;
}else {
return $this->page-1;
}
}
private function getOffset(){
return ($this->page-1)*$this->num;
}
private function getStartNum(){
if ($this->total==0) {
return 0;
}else {
相关新闻>>
- 发表评论
-
- 最新评论 更多>>