class Helper_Page{
/**總資訊數*/
var $infoCount;
/**總頁數*/
var $pageCount;
/**每頁顯示條數 */
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();
}
函數AdjustPageNo()
{
if($this->pageNo == '' || $this->pageNo $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;
回傳錯誤;
}
$this->nextPageNo = $nextPageNo;
回傳真;
}
/**
* 上一頁
*/
function GotoPrevPage()
{
$prevPageNo = $this->pageNo - 1;
if ($prevPageNo {
$this->prevPageNo = 1;
回傳錯誤;
}
$this->prevPageNo = $prevPageNo;
回傳真;
}
function GetPageCount()
{
return ceil($this->infoCount / $this->items);
}
function GetStartPos()
{
return ($this->pageNo - 1) * $this->items;
}
}
以上就介紹了http://www.12306.cn/mormhweb/k php相當簡單的分頁類,包括了http://www.12306.cn/mormhweb/k方面的內容,希望對PHP教程有興趣的朋友有幫助。