Common PHP encapsulation paging tools

Source: Internet
Author: User
This article mainly introduces frequently used PHP encapsulated paging tools for reference. if you are interested, you can refer to paging, which is usually used by every project, therefore, encapsulate it into a tool class and call it directly in the future (although the TP framework is very powerful, it is hard to seal it by yourself .), This saves both time and effort and generates 'employee scores '.

The paging tool class I provided is still complete, including the home page, previous page, next page, last page, and number of available pages (that is, when there are many pages, display only the number passed in according to the parameter), you can also choose whether to use the drop-down navigation page function as required.

 1? $ PageNum-1: 1; // when the page number is the first page, cancel the previous page button function $ strpage. = $ pageNum = 1? "Previous Page": "Previous page"; // The first page in the displayed page number list $ startPage = $ pageNum> $ pageMiddleVal? $ PageNum-$ pageMiddleCha: 1; // maximum starting page number = total page number-4 if ($ pageCount-$ pageMaxVal> 0 & $ startPage> $ pageCount-$ pageMaxVal) {$ startPage = $ pageCount-$ pageMaxVal;} // The last page number in the displayed page number list $ endPage = $ startPage <($ pageCount-$ pageMaxVal )? $ StartPage + $ pageMaxVal: $ pageCount; // The page number of the intermediate number for ($ I = $ startPage; $ I <= $ endPage; $ I ++) {if ($ I = $ pageNum) {$ strpage. = "$ I";} else {$ strpage. = "$ I" ;}}// next page $ nextNum = $ pageNum <$ pageCount? $ PageNum + 1: $ pageCount; // when the page number is the last page, the function of the next page button is canceled $ strpage. = $ pageNum = $ pageCount? "Next page": "next page"; // Last Page $ strpage. = "Last page"; // The total number of pages $ strpage. = "total page number: {$ pageCount}"; // determines whether the page number is selected. if ($ selected) {// select $ strpage. = "current page number:"; For ($ I = 1; $ I <= $ pageCount; $ I ++) {if ($ I ==$ pageNum) {$ strpage. ="$ I";} Else {$ strpage. ="$ I";}}$ Strpage. ="";}Return $ strpage ;}}

I hope you will continue to pay attention to the remaining MySQL knowledge.

The above is all the content of this article. I hope it will help you learn and support PHP.

For more articles about commonly used PHP encapsulation paging tools, please follow the PHP Chinese network!

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.