作者:瀟湘博客

時(shí)間: 2009-11-26

php技術(shù)群: 37304662

使用方法: include_once'Pager.class.php'; $pager=new Pager(); if(isset($_GET['page'])) $pager->setCurrentPage($_GET['p " /> 欧美日韩你懂的,亚洲日b,成人小视频在线免费观看

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

php google或baidu分頁代碼

復(fù)制代碼 代碼如下:
<?php
/**

作者:瀟湘博客

時(shí)間:
2009-11-26

php技術(shù)群:
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總頁數(shù)
**/
protected $pageTotal;
/**
*int
**/
protected $previous;
/**
*int
**/
protected $next;
/**
*int中間頁起始序號
**/
protected $startPage;
/**
*int中間頁終止序號
**/
protected $endPage;
/**
*int記錄總數(shù)
**/
protected $recorbTotal;
/**
*int每頁顯示記錄數(shù)
**/
protected $pageSize;
/**
*int當(dāng)前顯示頁
**/
protected $currentPage;
/**
*string基url地址
**/
protected $baseUri;

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

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

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

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

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

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

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

/**
*@paramint$recorbTotal設(shè)置獲取記錄總數(shù)
*/
public function setRecorbTotal($recorbTotal){
$this->recorbTotal=$recorbTotal;
}

/**
*構(gòu)造函數(shù)
**/
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;
}



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

php技術(shù)php google或baidu分頁代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 91精品国 | 亚洲成a人片在线v观看 | 不卡一区二区三区四区 | 欧美成人免费午夜影视 | 欧美性开放视频 | 欧美一区二区久久精品 | 99在线视频观看 | 激情文学图片 | 国产69成人免费视频观看 | 九九精品视频在线观看 | 四虎激情影院 | 天天做天天爱夜夜爽 | 婷婷四色 | 国产精品2019 | 99在线精品国产不卡在线观看 | 国内精品视频九九九九 | 五月天六月婷婷 | 在线视频 91 | 9久9久女女热精品视频免费观看 | 中文字幕在线国产 | 色女人天堂 | 一区二区网站在线观看 | 亚洲人成人网毛片在线播放 | 欧美亚洲综合激情在线 | 久视频免费精品6 | 欧美黑人xxxxx性受 | 久久夜色精品国产飘飘 | 婷婷激情综合网 | 午夜国产福利在线 | 99视频精品在线 | 色噜噜狠狠先锋影音久久 | 日韩中文字幕久久久经典网 | 69国产精品 | 中文精品久久久久国产网址 | 国产高清精品久久久久久久 | 一区二区高清视频 | 免费91麻豆精品国产自产在线观看 | 精品国产一区二区三区19 | 欧美怡红院免费全视频 | 国产一级在线观看www色 | 国产成人精品一区二三区 |