This article is mainly to use PHP functions to achieve digital and text paging, the implementation of the step is not wordy, directly on the code
/** * * @param $_sql * @param $_size */function _page ($_sql,$_size) {//Remove all variables inside, external access to global $_page,$_pagesize,$_p Agenum,$_pageabsolute,$_num; if (Isset ($_get[' page ')) {$_page = $_get[' page ']; if (Empty ($_page) | | $_page < 0 | |!is_numeric ($_page)) {$_page = 1; } else {$_page = Intval ($_page); }} else {$_page = 1; } $_pagesize = $_size; $_num = _num_rows (_query ($_sql)); if ($_num = = 0) {$_pageabsolute = 1; } else {$_pageabsolute = Ceil ($_num/$_pagesize); } if ($_page > $_pageabsolute) {$_page = $_pageabsolute; } $_pagenum = ($_page-1) * $_pagesize;} /** * _paging Paging function * @param $_type * @return back to pagination */function _paging ($_type) {global $_page,$_pageabsolute,$_num; if ($_type = = 1) {echo '; Echo '
'; for ($i =0; $i <$_pageabsolute; $i + +) {if ($_page = = ($i + 1)) {echo '
- '. ($i + 1). '
'; } else {echo '
- '. ($i + 1). '
'; }} Echo '
'; Echo '; } elseif ($_type = = 2) {echo '; Echo '
'; Echo '
- '. $_page. ' /'. $_pageabsolute. ' Page |
'; Echo '
- A total of '. $_num ' Members |
'; if ($_page = = 1) {echo '
- Home |
'; Echo '
- Prev |
'; } else {echo '
- Home |
'; Echo '
- Prev |
'; } if ($_page = = $_pageabsolute) {echo '
- Next Page |
'; Echo '
- Last
'; } else {echo '
- Next Page |
'; Echo '
- Last
'; } Echo '
'; Echo '; }}
Wrap the above code in the core library glob.funic.php
You can then simply call the following function in the file:
Copy the Code code as follows:
<?php}
_pageing function call paging, 1|2,1 for digital paging, 2 for text paging
_paging (2);
?>
The above is the PHP function to achieve digital and text pagination code of the entire content, I hope you can like.