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

MyZ分頁類

系統 2528 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條評論
主站蜘蛛池模板: 国产国语对白一级毛片 | 国产一区视频在线 | 日本1区二区三区公司 | 再猛点深使劲爽日本免费视频 | 99热这就是里面只有精品 | 国产一区二区三区免费观看 | 四虎影视永久免费视频观看 | 99久热成人精品视频 | 亚洲精品中文一区不卡 | 国产在线观看不卡 | 欧美一级片 在线播放 | 奇米线在人线免费视频 | 欧美成人毛片免费网站 | 日本高清二区 | 亚洲综合网站久久久 | 久久国产经典视频 | 国产在线欧美精品中文一区 | 99久久精品费精品国产 | 视频大全在线观看免费 | 亚洲高清在线视频 | 天天色天天射综合网 | 久久久久久毛片免费播放 | 日韩你懂得 | 国产在线五月综合婷婷 | 国产在线精品一区二区中文 | 亚洲欧洲免费视频 | 天天久久狠狠伊人第一麻豆 | 妇女网站爱嘿嘿视频免费观看 | 精品国产成人a在线观看 | 日本a在线视频 | 国产一级特黄aa级特黄裸毛片 | 亚洲高清在线观看看片 | 久久99国产精品久久欧美 | 国产亚洲精品一品区99热 | 日产一二三四五六七区麻豆 | 美日韩毛片 | 四虎永久免费884hutv | 日本免费一区视频 | 日韩久久久精品首页 | 国产在线观看91精品一区 | 日韩精品一区二区三区国语自制 |