PHP Pagination Class Code
1001, ' gid ' =>2008); * Output: [prev] 1<< [1] [2] [3] [4] [5] [6] [7] [8] [9] [ten] >>10 [next] */public static function sp Lit1 ($allItemTotal, $currPageNum, $pageSize, $pageName = ", $getParamList = Array ()) {if ($allItemTotal = = 0) return" ";//Page Face name if ($pageName = = ") {$url = $_server[' php_self ']."? Page= ";} else {$url = $pageName. "? Page= ";} Parameter $urlparamstr = ""; foreach ($getParamList as $key = = $val) {$urlParamStr. = "&". $key. " =". $val;} Calculates 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. ""; /Previous Page $prepage = ($currPageNum <= 1)? "Prev": "[prev]";//The next page shows $nextpage = ($currPageNum >= $pagesNum)? "Next page": "[Next Page]";//page by $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 two * * @param int $allItemTotal all record quantity * @param int $currPageNum Number of current page * @param int $pageSize The number of records to display per page * @ Param string $pageName The address of the current page, if it is empty, is automatically fetched by the system, the default is empty * @param array $getParamList The page needs to pass the URL parameter arrays, the array key represents the variable people, value represents the variable value * @return String returns the final parse out of the paged HTML code, which can be used directly with the * @example * echo pageStyle1 (2, +, ' s.php ', array (' ID ' =>1, ' name ' = = ' user ')); * * Output: Prev 1 2 3 4 5 Next [2] [GO] */public STATic function Split2 ($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;} Calculates the total number of pages $pagesnum = Ceil ($allItemTotal/$pageSize);//Previous page showing $prepage = ($currPageNum <= 1)? "Previous": "Previous";//The next page shows $nextpage = ($currPageNum >= $pagesNum)? "Next": "Next";//page by $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 all record quantity * @param int $currPageNum Number of current page * @param int $pageSize The number of records to display per page * @ Param string $pageName The address of the current page, if it is empty, is automatically fetched by the system, the default is empty * @param array $getParamList The page needs to pass the URL parameter arrays, the array key represents the variable people, value represents the variable value * @return String returns the final parse out of the paged HTML code, which can be used directly with the * @example * echo pageStyle1 (2, +, ' s.php ', array (' ID ' =>1, ' name ' = = ' user ')); * Output: Previous next */public static function Split3 ($allItemTotal, $currPageNum, $pageSize, $pageName = ", $getParamList = a Rray ()) {if ($allItemTotal = = 0) return "", or//page name if ($pageName = = ") {$url = $_server[' php_self ']."? Page= ";} else {$url = $pageName. "? Page= ";} Parameter $urlparamstr = ""; foreach ($getParamList as $key = = $val) {$urlParamStr. = "&". $key. " =". $val;} Calculates the total number of pages $pagesnum = Ceil ($allItemTotal/$pageSize);//Previous page showing $prepage = ($currPageNum <= 1)? "Previous": "Previous";//The next page shows $nextpage = ($currPageNum >= $pagesNum)? "Next": "Next"; $returnUrl = $prePage. "". $nextPage; return $reTurnurl;} /** * Pagination Display 4 * * @param int $allItemTotal all record quantity * @param int $currPageNum Number of current page * @param int $pageSiz E The number of records that need to be displayed per page * @param string $pageName The address of the current page, and if NULL is automatically obtained by the system, the default is null * @param array $getParamList URL parameter arrays that need to be passed in the page , the key in the array represents the variable people, and value represents the variable value * @return string returns the last parse out of the paged HTML code, which can be used directly with the * @example * echo pageStyle1 (50, 2, 10, ' s.php ', array (' ID ' =>1, ' name ' = ' user ')); * Output: 2nd 50 page prev 1 2 3 4 5 next 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= "; Calculates the total number of pages $pagesNum = Ceil ($allItemTotal/$pageSize); Previous page Shows $prePage = ($currPageNum <= 1)? "Prev": "Prev"; The next page shows $nextPage = ($currPageNum >= $pagesNum)? "Next page": "Next Page"; Show $listNums = "by page"\ 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. ' Shared '. $pagesNum. ' Page jump to '. $listNums. ' Page '; $script =<<
1, ' name ' = ' user '); * Output: 2nd 50 page prev 1 2 3 4 5 next jump to [] page [GO] * * public static function Split5 ($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= "; Calculates the total number of pages $pagesNum = Ceil ($allItemTotal/$pageSize); Previous page Shows $prePage = ($currPageNum <= 1)? "Prev": "Prev"; The next page shows $nextPage = ($currPageNum >= $pagesNum)? "Next page": "Next Page"; Display by Page $listNums = ""; for ($i = ($currPageNum-1); $i < ($currPageNum +4); $i + +) {if ($i < 1 | | $i > $pagesNum) continue; if ($i = = $currPageNum) $listNums. = "
". $i.""; else $listNums. = "". $i. ""; } $RETURNURL = '
section ' $currPageNum. ' /'. $pagesNum. ' Page'. $prePage. " ". $listNums. " ". $nextPage; $gotoForm = '
Jump toPage'; Return $RETURNURL. $gotoForm; }}/* Example: $allItemTotal = $currPageNum = isset ($_get[' page ')? $_get[' page ': 1; $pageSize = 5; $pageName = "; $getParamList = Array (' ClassID ' =>44); $pagination = new pagination (); echo $pagination->split1 ($allItemTotal, $currPageNum, $pageSize, $pageName, $getParamList). "
"Echo $pagination->split2 ($allItemTotal, $currPageNum, $pageSize, $pageName, $getParamList)."
"Echo $pagination->split3 ($allItemTotal, $currPageNum, $pageSize, $pageName, $getParamList)."
"Echo $pagination->split4 ($allItemTotal, $currPageNum, $pageSize, $pageName, $getParamList)."
"Echo $pagination->split5 ($allItemTotal, $currPageNum, $pageSize, $pageName, $getParamList)."
";*/?>