作者:瀟湘博客

時間: 2009-11-26

php技術群: 37304662

使用方法: include_once'Pager.class.php'; $pager=new Pager(); if(isset($_GET['page'])) $pager->setCurrentPage($_GET['p " /> 人人澡 人人澡 人人看欧美 ,亚洲综合网国产福利精品一区,欧美一区二区亚洲

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php google或baidu分頁代碼

復制代碼 代碼如下:
<?php
/**

作者:瀟湘博客

時間:
2009-11-26

php技術群:
37304662

使用方法:
include_once'Pager.class.php';
$pager=new Pager();
if(isset($_GET['page']))
$pager->setCurrentPage($_GET['page']);
else
$pager->setCurrentPage(1);

$pager->setRecorbTotal(1000);
$pager->setBaseUri("page.php?");
echo $pager->execute();

**/
class Pager{
/**
*int總頁數
**/
protected $pageTotal;
/**
*int
**/
protected $previous;
/**
*int
**/
protected $next;
/**
*int中間頁起始序號
**/
protected $startPage;
/**
*int中間頁終止序號
**/
protected $endPage;
/**
*int記錄總數
**/
protected $recorbTotal;
/**
*int每頁顯示記錄數
**/
protected $pageSize;
/**
*int當前顯示頁
**/
protected $currentPage;
/**
*string基url地址
**/
protected $baseUri;

/**
*@returnstring獲取基url地址
*/
public function getBaseUri(){
return$this->baseUri;
}

/**
*@returnint獲取當前顯示頁
*/
public function getCurrentPage(){
return $this->currentPage;
}

/**
*@returnint獲取每頁顯示記錄數
*/
public function getPageSize(){
return $this->pageSize;
}

/**
*@returnint獲取記錄總數
*/
public function getRecorbTotal(){
return$this->recorbTotal;
}

/**
*@paramstring$baseUri設置基url地址
*/
public function setBaseUri($baseUri){
$this->baseUri=$baseUri;
}

/**
*@paramint$currentPage設置當前顯示頁
*/
public function setCurrentPage($currentPage){
$this->currentPage=$currentPage;
}

/**
*@paramint$pageSize設置每頁顯示記錄數
*/
public function setPageSize($pageSize){
$this->pageSize=$pageSize;
}

/**
*@paramint$recorbTotal設置獲取記錄總數
*/
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.="<a href=/"".$this->baseUri."page=1/"><font style=/"font-family:webdings/">第1頁</font></a> <a href=/"".$this->baseUri."page=$this->previous/"><fontstyle=/"font-family:webdings/">前一頁</font></a>";
else
$result.="<font style=/"font-family:webdings/">第1頁</font> <font style=/"font-family:webdings/"></font>";

for($i=$this->startPage;$i<=$this->endPage;$i++){
if($this->currentPage==$i)
$result.="<font color=/"#ff0000/">$i</font>";
else
$result.=" <a href=/"".$this->baseUri."page=$i/">$i</a> ";
}

if($this->currentPage!=$this->pageTotal){
$result.="<a href=/"".$this->baseUri."page=$this->next/"><font style=/"font-family:webdings/">后一頁</font></a> ";
$result.="<a href=/"".$this->baseUri."page=$this->pageTotal/"><font style=/"font-family:webdings/">最后1頁</font></a>";
}else{
$result.="<font style=/"font-family:webdings/">最后1頁</font> <font style=/"font-family:webdings/"></font>";
}
return $result;
}



/**
*執行分頁
**/
public function execute(){
if($this->baseUri!=""&&$this->recorbTotal==0)
return"";
$this->arithmetic();
return $this->pageStyle();
}
}
?>

php技術php google或baidu分頁代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: yellow中文字幕久久网 | 欧美黑人巨大日本人又爽又色 | 亚洲线精品久久一区二区三区 | 肉色丝袜一区二区高跟鞋 | 日本理论午夜中文字幕第一页 | 99re6这里只有精品视频 | 好爽毛片一区二区三区四区 | 国产成人禁片在线观看 | 精品国产品国语在线不卡丶 | 欧美色欧美亚洲高清在线观看 | 色爱区综合激月婷婷激情五月 | 视频麻豆 | 看全色黄大色黄大片免责看 | 综合区小说区图片区在线一区 | 在线看污视频 | 亚洲国产欧美另类 | 亚洲成年网 | 55夜色66夜色国产精品站 | 美国三级日本三级久久99 | 国产真实伦在线视频免费观看 | 欧美人善zozσ性伦交 | 久精品在线观看 | 国产高清精品一级毛片 | 精品三区| 99精品视频在线在线视频观看 | 热伊人99re久久精品最新地 | 91久久国产综合精品女同国语 | 国产成人福利免费视频 | 大象焦伊人久久综合网色视 | 伊人色综合一区二区三区 | 色黄视频在线观看 | 2021国产精品自在拍在线播放 | 久久国产精品偷 | 国产小视频在线免费 | 国产欧美自拍视频 | 欧美三级成人 | 五月天六月婷婷开心激情 | 丁香婷婷综合五月综合色啪 | 午夜免费的国产片在线观看 | 中文字幕一区二区三区免费看 | 婷婷六月久久综合丁香可观看 |