亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

MyZ分頁類

系統 2230 0

版權聲明:原創作品,允許轉載,轉載時請務必以超鏈接形式標明文章原始出版、作者信息和本聲明。否則將追究法律責任。 http://blog.csdn.net/mayongzhan - 馬永占,myz,mayongzhan

花了點時間寫了個分頁類,看著還不錯,測試了下能用,離實際應用應該就剩一個樣式了.

_tatal等等之所以要寫成帶下劃線,是因為這些內容需要帶入到地址欄中,實際當中可能會重名

link的作用是有時得到的數據是為了使分頁跳轉的時候帶上參數

寫很比教長的時間.有點模仿小李的分頁,沒加樣式,這樣更好

<!-- 分頁類 , 加測試 ~~~ -->

<? php

/* *

*@nametest.php

*@dateWedDec0521:49:45CST2007

*@copyright馬永占(MyZ)

*@author馬永占(MyZ)

*@linkhttp://blog.csdn.net/mayongzhan/

*/



class Pager

{

private $_tatal ; // 總數,記錄的總條數

private $_nowPage = 1 ; // 當前頁

private $_rows = 40 ; // 行數

private $pages ; // 頁數,可以通過總數和行數計算出來

private $dataBegin = 0 ; // sql語句limit開始的數字,可以通過行數和當前頁計算出來

private $dataCount = 40 ; // sql語句limit取的數據量,根據行數來決定

private $link = '' ; // 分頁帶的其他參數

private $showCount = 10 ; // 頁碼顯示量

public function set_tatal( $_tatal )

{

$this -> _tatal = $_tatal ;

}

public function set_nowPage( $_nowPage )

{

$this -> _nowPage = $_nowPage ;

}

public function set_rows( $_rows )

{

$this -> _rows = $_rows ;

}

public function setLink( $link )

{

$this -> link = $link ;

}

public function setShowCount( $showCount )

{

$this -> showCount = $showCount ;

}

public function setPages()

{

$this -> pages = ( $this -> _tatal - $this -> _tatal % $this -> _rows) / $this -> _rows

+ intval ( $this -> _tatal % $this -> _rows == 0 ? 0 : 1 );

}

public function getDataBegin()

{

$this -> dataBegin = $this -> _nowPage * $this -> _rows;

return $this -> dataBegin;

}

public function getDataCount()

{

$this -> dataCount = $this -> _rows;

return $this -> dataCount;

}



public function createPager() // 創建分頁

{

$pagerList = ' <div> ' ;

// 首頁

if ( $this -> _nowPage > $this -> showCount && $this -> _nowPage != 1 ){

$pagerList = ' &nbsp;<ahref="? ' . $this -> link . '

&_tatal=
' . $this -> _tatal . '

&_rows=
' . $this -> _rows . '

&_nowPage=1"

title="首頁">1</a>&nbsp;...
' ;

}

// 前翻N頁

if ( $this -> _nowPage > $this -> showCount){

$pagerList .= ' &nbsp;<ahref="? ' . $this -> link . '

&_tatal=
' . $this -> _tatal . '

&_rows=
' . $this -> _rows . '

&_nowPage=
' . ( $this -> _nowPage - $this -> showCount) . ' "

title="前
' . $this -> showCount . ' 頁"><<</a> ' ;

}

// 前1頁

if ( $this -> _nowPage != 1 ){

$pagerList .= ' &nbsp;<ahref="? ' . $this -> link . '

&_tatal=
' . $this -> _tatal . '

&_rows=
' . $this -> _rows . '

&_nowPage=
' . ( $this -> _nowPage - 1 ) . ' "

title="前1頁"><</a>
' ;

}

$nowPageGroup = $this -> nowPageGroup(); // 得到當前頁大分頁

$beginNowPage = ( $nowPageGroup - 1 ) * $this -> showCount + 1 ; // 得到開始的頁碼

$i = 0 ;

while ( $beginNowPage <= $this -> pages && $i < 10 ){

if ( $beginNowPage != $this -> _nowPage){

$pagerList .= ' &nbsp;<ahref="? ' . $this -> link . '

&_tatal=
' . $this -> _tatal . '

&_rows=
' . $this -> _rows . '

&_nowPage=
' . $beginNowPage . ' "

title="第
' . $beginNowPage . ' 頁"> ' . $beginNowPage . ' </a> ' ;

}

else {

$pagerList .= ' &nbsp; ' . $beginNowPage ;

}

$i ++ ;

$beginNowPage ++ ;

}

// 后1頁

if ( $this -> _nowPage != $this -> pages){

$pagerList .= ' &nbsp;<ahref="? ' . $this -> link . '

&_tatal=
' . $this -> _tatal . '

&_rows=
' . $this -> _rows . '

&_nowPage=
' . ( $this -> _nowPage + 1 ) . ' "

title="后1頁">></a>
' ;

}

// 后翻N頁

if ( $this -> pages > $this -> showCount && $this -> lastShow()){

$pagerList .= ' &nbsp;<ahref="? ' . $this -> link . '

&_tatal=
' . $this -> _tatal . '

&_rows=
' . $this -> _rows . '

&_nowPage=
' . ( $this -> _nowPage + $this -> showCount) . ' "

title="后
' . $this -> showCount . ' 頁">>></a> ' ;

}

// 末頁

if ( $this -> pages > $this -> showCount && $this -> lastShow()){

$pagerList .= ' &nbsp;...&nbsp;<ahref="? ' . $this -> link . '

&_tatal=
' . $this -> _tatal . '

&_rows=
' . $this -> _rows . '

&_nowPage=
' . $this -> pages . ' "

title="末頁">
' . $this -> pages . ' </a> ' ;

}

$pagerList .= ' &nbsp;&nbsp;&nbsp;( ' ;

$pagerList .= ' 跳轉到<inputname="custompage"size="3"value=" ' . $this -> _nowPage . ' "onkeydown="if(event.keyCode==13){window.location= ' ? ' .$this->link. ' & _tatal = ' .$this->_tatal. ' & _rows = ' .$this->_rows. ' & _nowPage = ' +this.value+ '' ;returnfalse;}"type="text"/>/ ' . $this -> pages;

$pagerList .= ' ,每頁<inputname="custompage"size="3"value=" ' . $this -> _rows . ' "onkeydown="if(event.keyCode==13){window.location= ' ? ' .$this->link. ' & _tatal = ' .$this->_tatal. ' & _rows = ' +this.value+ ' & _nowPage = 1 ' ;returnfalse;}"type="text"/>行/ ' . $this -> _rows;

$pagerList .= ' )</div> ' ;

return $pagerList ;

}



private</spa
分享到:
評論

MyZ分頁類


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日韩国产在线 | 大尺度视频网站久久久久久久久 | 天天曰天天操 | 国产伦理一区二区三区 | 久久精品一区二区 | 中文字幕日本一区波多野不卡 | 精品福利在线 | 国产麻豆久久 | 天天曰天天干天天操 | 99视频全部免费精品全部四虎 | 国产精品视频一区二区三区不卡 | 伊人久久丁香色婷婷啪啪 | 日本 欧美 国产 | 在线播放heyzo北条麻妃 | 亚洲精品一区henhen色 | 新香蕉视频在线 | 成人欧美视频在线观看播放 | 免费看特级毛片 | 日韩在线中文 | 自拍 欧美 在线 综合 另类 | 久久精品国产视频 | 青青青国产精品国产精品久久久久 | 午夜色影院| 国产精品va一区二区三区 | 亚洲精品成人456在线播放 | 日日狠狠久久偷偷四色综合免费 | 日日摸日日添日日透 | 香蕉视频在线免费看 | 久久久久久久久久综合情日本 | 欧美成人一区二区三区 | 国产成人精品男人的天堂网站 | 嫩草成人国产精品 | 日本黄色网址免费 | 亚洲swag精品自拍一区 | 欧美日韩免费播放一区二区 | 国产真实乱子伦精品视 | 精品国产精品久久一区免费式 | 精品小视频在线 | 最近中文字幕无吗免费视频 | 五月婷婷六月综合 | 亚洲视频观看 |