栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

php google或baidu分页代码

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

php google或baidu分页代码

复制代码 代码如下:

class Pager{

protected $pageTotal;

protected $previous;

protected $next;

protected $startPage;

protected $endPage;

protected $recorbTotal;

protected $pageSize;

protected $currentPage;

protected $baseUri;


public function getbaseUri(){
return$this->baseUri;
}


public function getCurrentPage(){
return $this->currentPage;
}


public function getPageSize(){
return $this->pageSize;
}


public function getRecorbTotal(){
return$this->recorbTotal;
}


public function setbaseUri($baseUri){
$this->baseUri=$baseUri;
}


public function setCurrentPage($currentPage){
$this->currentPage=$currentPage;
}


public function setPageSize($pageSize){
$this->pageSize=$pageSize;
}


public function setRecorbTotal($recorbTotal){
$this->recorbTotal=$recorbTotal;
}


public function __construct()
{
$this->pageTotal=0;
$this->previous=0;
$this->next=0;
$this->startPage=0;
$this->endPage=0;

$this->pageSize=20;
$this->currentPage=0;
}


private function arithmetic(){
if($this->currentPage<1)
$this->currentPage=1;

$this->pageTotal=floor($this->recorbTotal/$this->pageSize)+($this->recorbTotal%$this->pageSize>0?1:0);

if($this->currentPage>1&&$this->currentPage>$this->pageTotal)
header('location:'.$this->baseUri.'page='.$this->pageTotal);

$this->next=$this->currentPage+1;
$this->previous=$this->currentPage-1;

$this->startPage=($this->currentPage+5)>$this->pageTotal?$this->pageTotal-10:$this->currentPage-5;
$this->endPage=$this->currentPage<5?11:$this->currentPage+5;

if($this->startPage<1)
$this->startPage=1;

if($this->pageTotal<$this->endPage)
$this->endPage=$this->pageTotal;
}




protected function pageStyle(){
$result="共".$this->pageTotal."页";

if($this->currentPage>1)
$result.="baseUri."page=1">第1页 baseUri."page=$this->previous">前一页";
else
$result.="第1页 ";

for($i=$this->startPage;$i<=$this->endPage;$i++){
if($this->currentPage==$i)
$result.="$i";
else
$result.=" baseUri."page=$i">$i ";
}

if($this->currentPage!=$this->pageTotal){
$result.="baseUri."page=$this->next">后一页 ";
$result.="baseUri."page=$this->pageTotal">最后1页";
}else{
$result.="最后1页 ";
}
return $result;
}
public function execute(){
if($this->baseUri!=""&&$this->recorbTotal==0)
return"";
$this->arithmetic();
return $this->pageStyle();
}
}
?>

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/52495.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号