Php is a simple paging class. ClassHelper_Page {** Total number of information * var $ infoCount; ** Total number of pages * var $ pageCount; ** number of entries per page * var $ items; ** Current page number * var $ pageNo; ** start position of the query class Helper_Page {
/** Total information count */
Var $ infoCount;
/** Total Page number */
Var $ pageCount;
/** Number of Entries displayed per page */
Var $ items;
/** Current page number */
Var $ pageNo;
/** Start position of the query */
Var $ startPos;
/** Next page */
Var $ nextPageNo;
/** Previous page */
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;
}
/**
* Next page
*/
Function GoToNextPage ()
{
$ NextPageNo = $ this-> pageNo + 1;
If ($ nextPageNo> $ this-> pageCount)
{
$ This-> nextPageNo = $ this-> pageCount;
Return false;
}
$ This-> nextPageNo = $ nextPageNo;
Return true;
}
/**
* Previous page
*/
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;
}
}
Http://www.bkjia.com/PHPjc/319494.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319494.htmlTechArticleclass Helper_Page {/** Total number of information */var $ infoCount;/** Total number of pages */var $ pageCount;/** number of entries per page */var $ items; /** Current page number */var $ pageNo;/** start position of the query...