php相當(dāng)簡(jiǎn)單的分頁(yè)類(lèi)
更新時(shí)間:2008年10月02日 01:14:05 作者:
代碼比較簡(jiǎn)單,學(xué)習(xí)php類(lèi)的朋友,可以看下
class Helper_Page{
/** 總信息數(shù) */
var $infoCount;
/** 總頁(yè)數(shù) */
var $pageCount;
/** 每頁(yè)顯示條數(shù) */
var $items;
/** 當(dāng)前頁(yè)碼 */
var $pageNo;
/** 查詢(xún)的起始位置 */
var $startPos;
/** 下一頁(yè) */
var $nextPageNo;
/** 上一頁(yè) */
var $prevPageNo;
function Helper_Page($infoCount, $items, $pageNo)
{
$this->infoCount = $infoCount;
$this->items = $items;
$this->pageNo = $pageNo;
$this->pageCount = $this->GetPageCount();
$this->AdjustPageNo();
$this->startPos = $this->GetStartPos();
}
function AdjustPageNo()
{
if($this->pageNo == '' || $this->pageNo < 1)
$this->pageNo = 1;
if ($this->pageNo > $this->pageCount)
$this->pageNo = $this->pageCount;
}
/**
* 下一頁(yè)
*/
function GoToNextPage()
{
$nextPageNo = $this->pageNo + 1;
if ($nextPageNo > $this->pageCount)
{
$this->nextPageNo = $this->pageCount;
return false;
}
$this->nextPageNo = $nextPageNo;
return true;
}
/**
* 上一頁(yè)
*/
function GotoPrevPage()
{
$prevPageNo = $this->pageNo - 1;
if ($prevPageNo < 1)
{
$this->prevPageNo = 1;
return false;
}
$this->prevPageNo = $prevPageNo;
return true;
}
function GetPageCount()
{
return ceil($this->infoCount / $this->items);
}
function GetStartPos()
{
return ($this->pageNo - 1) * $this->items;
}
}
/** 總信息數(shù) */
var $infoCount;
/** 總頁(yè)數(shù) */
var $pageCount;
/** 每頁(yè)顯示條數(shù) */
var $items;
/** 當(dāng)前頁(yè)碼 */
var $pageNo;
/** 查詢(xún)的起始位置 */
var $startPos;
/** 下一頁(yè) */
var $nextPageNo;
/** 上一頁(yè) */
var $prevPageNo;
function Helper_Page($infoCount, $items, $pageNo)
{
$this->infoCount = $infoCount;
$this->items = $items;
$this->pageNo = $pageNo;
$this->pageCount = $this->GetPageCount();
$this->AdjustPageNo();
$this->startPos = $this->GetStartPos();
}
function AdjustPageNo()
{
if($this->pageNo == '' || $this->pageNo < 1)
$this->pageNo = 1;
if ($this->pageNo > $this->pageCount)
$this->pageNo = $this->pageCount;
}
/**
* 下一頁(yè)
*/
function GoToNextPage()
{
$nextPageNo = $this->pageNo + 1;
if ($nextPageNo > $this->pageCount)
{
$this->nextPageNo = $this->pageCount;
return false;
}
$this->nextPageNo = $nextPageNo;
return true;
}
/**
* 上一頁(yè)
*/
function GotoPrevPage()
{
$prevPageNo = $this->pageNo - 1;
if ($prevPageNo < 1)
{
$this->prevPageNo = 1;
return false;
}
$this->prevPageNo = $prevPageNo;
return true;
}
function GetPageCount()
{
return ceil($this->infoCount / $this->items);
}
function GetStartPos()
{
return ($this->pageNo - 1) * $this->items;
}
}
您可能感興趣的文章:
- 精美漂亮的php分頁(yè)類(lèi)代碼
- ThinkPHP使用心得分享-分頁(yè)類(lèi)Page的用法
- PHP通用分頁(yè)類(lèi)page.php[仿google分頁(yè)]
- mysql+php分頁(yè)類(lèi)(已測(cè))
- 高效mongodb的php分頁(yè)類(lèi)(不使用skip)
- php封裝的page分頁(yè)類(lèi)完整實(shí)例
- PHP 分頁(yè)類(lèi)(模仿google)-面試題目解答
- 仿dedecms下拉分頁(yè)樣式修改的thinkphp分頁(yè)類(lèi)實(shí)例
- 仿Aspnetpager的一個(gè)PHP分頁(yè)類(lèi)代碼 附源碼下載
- php仿ZOL分頁(yè)類(lèi)代碼
- PHP封裝的完整分頁(yè)類(lèi)示例
相關(guān)文章
php 根據(jù)自增id創(chuàng)建唯一編號(hào)類(lèi)
本文主要介紹了php根據(jù)自增id創(chuàng)建唯一編號(hào)類(lèi)的相關(guān)知識(shí)。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧2017-04-04PHP圖像處理技術(shù)實(shí)例總結(jié)【繪圖、水印、驗(yàn)證碼、圖像壓縮】
這篇文章主要介紹了PHP圖像處理技術(shù),結(jié)合實(shí)例形式總結(jié)分析了php繪圖、水印、驗(yàn)證碼、圖像壓縮等相關(guān)函數(shù)、功能與圖形繪制實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-12-12采用memcache在web集群中實(shí)現(xiàn)session的同步會(huì)話(huà)
這篇文章主要介紹了采用memcache在web集群中實(shí)現(xiàn)session的同步會(huì)話(huà),需要的朋友可以參考下2014-07-07遞歸實(shí)現(xiàn)php數(shù)組轉(zhuǎn)xml的代碼分享
本文以實(shí)例形式講述了PHP實(shí)現(xiàn)數(shù)組遞歸轉(zhuǎn)義的方法,分享給大家供大家參考之用。具體方法如下:2015-05-05php字符串函數(shù)學(xué)習(xí)之strstr()
這篇文章主要介紹了php字符串函數(shù)學(xué)習(xí)之strstr(),本文講解了它的定義和用法、參數(shù)描述、提示和注釋以及多個(gè)使用示例,需要的朋友可以參考下2015-03-03探討如何把session存入數(shù)據(jù)庫(kù)
本篇文章是對(duì)如何把session存入數(shù)據(jù)庫(kù)的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06php數(shù)組保存文本與文本反編成數(shù)組實(shí)例
這篇文章主要介紹了php數(shù)組保存文本與文本反編成數(shù)組的方法,通過(guò)兩個(gè)自定義函數(shù)string2array與array2string實(shí)例展示了php數(shù)組保存文本與文本反編成數(shù)組的實(shí)現(xiàn)方法,具有不錯(cuò)的參考借鑒價(jià)值,需要的朋友可以參考下2014-11-11