php相當簡單的分頁類
更新時間:2008年10月02日 01:14:05 作者:
代碼比較簡單,學習php類的朋友,可以看下
class Helper_Page{
/** 總信息數(shù) */
var $infoCount;
/** 總頁數(shù) */
var $pageCount;
/** 每頁顯示條數(shù) */
var $items;
/** 當前頁碼 */
var $pageNo;
/** 查詢的起始位置 */
var $startPos;
/** 下一頁 */
var $nextPageNo;
/** 上一頁 */
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;
}
/**
* 下一頁
*/
function GoToNextPage()
{
$nextPageNo = $this->pageNo + 1;
if ($nextPageNo > $this->pageCount)
{
$this->nextPageNo = $this->pageCount;
return false;
}
$this->nextPageNo = $nextPageNo;
return true;
}
/**
* 上一頁
*/
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;
/** 總頁數(shù) */
var $pageCount;
/** 每頁顯示條數(shù) */
var $items;
/** 當前頁碼 */
var $pageNo;
/** 查詢的起始位置 */
var $startPos;
/** 下一頁 */
var $nextPageNo;
/** 上一頁 */
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;
}
/**
* 下一頁
*/
function GoToNextPage()
{
$nextPageNo = $this->pageNo + 1;
if ($nextPageNo > $this->pageCount)
{
$this->nextPageNo = $this->pageCount;
return false;
}
$this->nextPageNo = $nextPageNo;
return true;
}
/**
* 上一頁
*/
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;
}
}
相關(guān)文章
PHP圖像處理技術(shù)實例總結(jié)【繪圖、水印、驗證碼、圖像壓縮】
這篇文章主要介紹了PHP圖像處理技術(shù),結(jié)合實例形式總結(jié)分析了php繪圖、水印、驗證碼、圖像壓縮等相關(guān)函數(shù)、功能與圖形繪制實現(xiàn)技巧,需要的朋友可以參考下2018-12-12采用memcache在web集群中實現(xiàn)session的同步會話
這篇文章主要介紹了采用memcache在web集群中實現(xiàn)session的同步會話,需要的朋友可以參考下2014-07-07遞歸實現(xiàn)php數(shù)組轉(zhuǎn)xml的代碼分享
本文以實例形式講述了PHP實現(xiàn)數(shù)組遞歸轉(zhuǎn)義的方法,分享給大家供大家參考之用。具體方法如下:2015-05-05