php面向对象分页类代码-成都快上网建站

php面向对象分页类代码

maxRows = $maxRows;
$this->pageSize= $pageSize;
//获取当前页
$this->page = isset($_GET['p'])?$_GET['p']:1;
$this->getMaxPage();
$this->checkPage();
//获取和封装url地址
$this->url = $_SERVER["PHP_SELF"];
$this->getParams();
}
//获取分页信息
public function limit(){
return (($this->page-1)*$this->pageSize).",".$this->pageSize;
}
//计算分页中的最大页数
private function getMaxPage(){
$this->maxPage = ceil($this->maxRows/$this->pageSize);
}
//判断当前页数是否越界
private function checkPage(){
if($this->page>$this->maxPage){
$this->page = $this->maxPage;
}
if($this->page<1){
$this->page=1;
}
}
//封装url上搜索条件
private function getParams(){
foreach($_GET as $k=>$v){
if($k!="p" && !empty($v)){
$this->params.="&{$k}={$v}";
}
}
}
//生成分页HTML代码
public function show(){
$str = "";
$str.= "当前第{$this->page}/{$this->maxPage}页 共计{$this->maxRows}条 ";
$str.= " 首页 ";
$str.= " 上一页 ";
$str.= " 下一页 ";
$str.= " 末页 ";
return $str;
}
}

网站栏目:php面向对象分页类代码
网页网址:http://kswjz.com/article/ihpsdh.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流