PHP google または baidu ページング コード_PHP チュートリアル

WBOY
リリース: 2016-07-21 15:43:15
オリジナル
906 人が閲覧しました

コードをコピーします コードは次のとおりです:

/**

作成者: Xiaoxiang ブログ

時間:
2009-11-26

php 技術グループ:
37304662

使用法:
include_once'Pager.class.php';
if ( isset($_GET['page']))
$pager->setCurrentPage($_GET['page']);
else
$pager->setCurrentPage(1); 1000);
$pager->setBaseUri("page.php?");
echo $pager->execute();*/
class Pager{
/**
*int 総ページ数
**/
protected $pageTotal;
/**
*int前のページ
**/
protected $previous;
/**
*次のページ
**/
保護された$next;
/**
*int 中間ページの開始シーケンス番号
**/
protected $startPage;
/**
*int 中間ページ終了シーケンス番号
**/
protected $endPage;
/**
*int 合計レコード数
**/
protected $recorbTotal;
/**
*int はページごとのレコード数を表示します
**/
protected $pageSize;
/**
*現在表示されているページ
**/
protected $currentPage;
/**
*文字列ベース URL アドレス
**/
protected $baseUri;

/**
*@returnstring ベース URL アドレスを取得します
*/
パブリック関数 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 アドレスを設定します
*/
パブリック関数 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;
}

/**
*コンストラクター
**/
パブリック関数 __construct()
{
$this->pageTotal=0;
$this->previous=0;
$this->next=0;
$this->startPage=0;
$this->endPage=0;

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

/**
*ページングアルゴリズム
**/
プライベート関数 arithmetic(){
if($this->currentPage$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->currentPagecurrentPage+5;

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

if($this->pageTotalendPage)
$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.="< ;font color="#ff0000">$i";
else
$result.=" baseUri."page=$i">$i ";
}

if($this->currentPage!=$this->pageTotal){
$result.="baseUri."page=$this->next ">次のページ ";
$result.="pageTotal">最後の 1 ページ";
}else{
$ result.= "最後のページ "; }



/**
*ページングを実行します
**/
パブリック関数execute(){
if($this->baseUri!=""&&$this->recorbTotal==0)
return""; $this->算術();
return $this->pageStyle()
}
}
?>




http://www.bkjia.com/PHPjc/320801.html

www.bkjia.com

http://www.bkjia.com/PHPjc/320801.html技術記事次のようにコードをコピーします。 ?php /** 著者: Xiaoxiang ブログ時間: 2009-11-26 PHP テクノロジー グループ: 37304662 使用法: include_once'Pager.class.php'; $pager=new Pager(); ...
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!