Php paging code

Source: Internet
Author: User
Php paging code & lt ;? Php *** simple paging class ** classPagination {*** pagination display style ** @ paramint $ allItemTotal number of all records * @ paramint $ currPageNum current page count * @ paramint $ pageSize php paging code
 1001, 'gid' => 2008); ** output: [Previous Page] 1 <[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]> 10 [next Page] */public static function split1 ($ allItemTotal, $ currPageNum, $ pageSize, $ pageName = '', $ getParamList = array () {if ($ allItemTotal = 0) return ""; // page name if ($ pageName = '') {$ url = $ _ SERVER ['php _ SELF ']. "? Page = ";} else {$ url = $ pageName ."? Page = ";}// parameter $ urlParamStr =" "; foreach ($ getParamList as $ key => $ val) {$ urlParamStr. = "&". $ key. "= ". $ val;} // calculate the total number of pages $ pagesNum = ceil ($ allItemTotal/$ pageSize); // The first page shows $ firstPage = ($ currPageNum <= 1 )? $ CurrPageNum ."<":" 1 <"; // The last page shows $ lastPage = ($ currPageNum >=$ pagesNum )? ">>". $ CurrPageNum:" >>". $ pagesNum. ""; // the previous page shows $ prePage = ($ currPageNum <= 1 )? "Previous Page": "[previous page]"; // the next page shows $ nextPage = ($ currPageNum >=$ pagesNum )? "Next page": "[Next Page]"; // display by page $ listNums = ""; for ($ I = ($ currPageNum-4 ); $ I <($ currPageNum + 9); $ I ++) {if ($ I <1 | $ I> $ pagesNum) continue; if ($ I ==$ currPageNum) $ listNums. = "[". $ I. "]"; else $ listNums. = "[". $ I. "]" ;}$ returnUrl = $ prePage. "". $ firstPage. "". $ listNums. "". $ lastPage. "". $ nextPage; return $ returnUrl;}/*** pagination display style 2 ** @ param int $ allItemTotal total number of all records * @ param int $ currPageNum current number of pages * @ Param int $ pageSize the number of records to be displayed on each page * @ param string $ address of the current page of pageName. if it is null, it is automatically obtained by the system, the default value is blank * @ param array $ the URL parameter array to be passed on the getParamList page. the key in the array represents the variable, value indicates the variable value * @ return string returns and finally parses the paging HTML code. you can directly use * @ example * echo pageStyle1 (50, 2, 10,'s. php ', array ('id' => 1, 'name' => 'user'); ** output: previous Page 1 2 3 4 5 Next Page [2] [GO] */public static function split2 ($ allItemTotal, $ currPageNum, $ pageSize, $ pageName = '', $ g EtParamList = array () {if ($ allItemTotal = 0) return "; // page name if ($ pageName = '') {$ url = $ _ SERVER ['php _ SELF ']. "? Page = ";} else {$ url = $ pageName ."? Page = ";}// parameter $ urlParamStr =" "; foreach ($ getParamList as $ key => $ val) {$ urlParamStr. = "&". $ key. "= ". $ val;} // calculate the total number of pages $ pagesNum = ceil ($ allItemTotal/$ pageSize); // the previous page shows $ prePage = ($ currPageNum <= 1 )? "Previous Page": "Previous page"; // displayed on the next page $ nextPage = ($ currPageNum >=$ pagesNum )? "Next page": "next page"; // display by page $ listNums = ""; for ($ I = ($ currPageNum-4); $ I <($ currPageNum + 9 ); $ I ++) {if ($ I <1 | $ I> $ pagesNum) continue; if ($ I ==$ currPageNum) $ listNums. = "". $ I. ""; else $ listNums. = "". $ I. "" ;}$ returnUrl = $ prePage. "". $ listNums. "". $ nextPage; $ gotoForm =''; Return $ returnUrl. $ gotoForm ;} /*** pagination display style three ** @ param int $ allItemTotal number of all records * @ param int $ currPageNum current number of pages * @ param int $ pageSize the number of records to be displayed on each page * @ param string $ address of the current page of pageName, if it is null, it is automatically obtained by the system. the default value is null * @ param array $ the URL parameter array to be passed on the getParamList page. the key in the array represents the variable, value indicates the variable value * @ return string returns and finally parses the paging HTML code. you can directly use * @ example * echo pageStyle1 (50, 2, 10,'s. php ', array ('id' => 1, 'name' => 'user'); ** output: Previous Page next page */public static function split3 ($ allItemTotal, $ currPageNum, $ pageSize, $ pageName = '', $ getParamList = array ()) {if ($ allItemTotal = 0) return ""; // page name if ($ pageName = '') {$ url = $ _ SERVER ['php _ SELF ']. "? Page = ";} else {$ url = $ pageName ."? Page = ";}// parameter $ urlParamStr =" "; foreach ($ getParamList as $ key => $ val) {$ urlParamStr. = "&". $ key. "= ". $ val;} // calculate the total number of pages $ pagesNum = ceil ($ allItemTotal/$ pageSize); // the previous page shows $ prePage = ($ currPageNum <= 1 )? "Previous Page": "Previous page"; // displayed on the next page $ nextPage = ($ currPageNum >=$ pagesNum )? "Next page": "next page"; $ returnUrl = $ prePage. "". $ nextPage; return $ returnUrl ;} /*** display by page 4 ** @ param int $ allItemTotal number of all records * @ param int $ currPageNum current page count * @ param int $ pageSize the number of records to be displayed on each page * @ param string $ address of the current page of pageName, if it is null, it is automatically obtained by the system. the default value is null * @ param array $ the URL parameter array to be passed on the getParamList page. the key in the array represents the variable, value indicates the variable value * @ return string returns and finally parses the paging HTML code. you can directly use * @ example * echo pageStyle1 (50, 2, 10,'s. php', Rray ('id' => 1, 'name' => 'user'); ** output: page 2/50 Previous Page 1 2 3 4 5 Next Page jump to [] Page [GO] */public static function split4 ($ allItemTotal, $ currPageNum, $ pageSize, $ pageName = '', $ getParamList = array () {if ($ allItemTotal = 0) return ""; // page name if ($ pageName = '') {$ url = $ _ SERVER ['php _ SELF ']. "? Page = "; $ formUrl = $ _ SERVER ['php _ SELF ']."? ";} Else {$ url = $ pageName ."? Page = "; $ formUrl = $ pageName ."? ";}// Parameter $ urlParamStr =" "; foreach ($ getParamList as $ key => $ val) {$ urlParamStr. = "&". $ key. "= ". $ val;} $ formUrl. = $ urlParamStr. "& page ="; // calculate the total number of pages $ pagesNum = ceil ($ allItemTotal/$ pageSize); // the previous page shows $ prePage = ($ currPageNum <= 1 )? "Previous Page": "Previous page"; // displayed on the next page $ nextPage = ($ currPageNum >=$ pagesNum )? "Next page": "next page"; // display by page $ listNums ="\ N "; for ($ I = 1; $ I <= $ pagesNum; $ I ++) {if ($ I <1 | $ I> $ pagesNum) continue; if ($ I ==$ currPageNum) $ listNums. ="{$ I}\ N "; else $ listNums. ="{$ I}\ N ";}$ listNums. ="\ N "; $ returnUrl = $ prePage.''. $ nextPage. 'Total'. $ pagesNum. 'page jumps to'. $ listNums. "page"; $ script = <
 

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.