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!