Php is a simple paging class _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.