The pagination effects of numbers and text in PHP self-training projects are implemented in functions,
/***** @ Param $ _ SQL * @ param $ _ size */function _ page ($ _ SQL, $ _ size) {// obtain all the variables in the Table. Externally, you can access global $ _ page, $ _ pagesize, $ _ pagenum, $ _ 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 function * @ param $ _ type * @ return returns pagination */function _ pag Ing ($ _ type) {global $ _ page, $ _ pageabsolute, $ _ num; if ($ _ type = 1) {echo '<div id = "page_num">'; echo '<ul>'; for ($ I = 0; $ I <$ _ pageabsolute; $ I ++) {if ($ _ page = ($ I + 1) {echo '<li> <a href = "blog. php? Page = '. ($ I + 1 ). '"class =" selected "> '. ($ I + 1 ). '</a> </li>';} else {echo '<li> <a href = "blog. php? Page = '. ($ I + 1 ). '"> '. ($ I + 1 ). '</a> </li>';} echo '</ul>'; echo '</div>';} elseif ($ _ type = 2) {echo '<div id = "page_text">'; echo '<ul>'; echo '<li> '. $ _ page. '/'. $ _ pageabsolute. 'page | </li>'; echo '<li> total <strong> '. $ _ num. '</strong> Members | </li>'; if ($ _ page = 1) {echo '<li> homepage | </li> '; echo '<li> Previous Page | </li>';} else {echo '<li> <a href = "'. SCRIPT. '. php "> homepage </a> | </li> '; echo' <li> <a href = "'. SCRIPT. '. ph P? Page = '. ($ _ page-1 ). '"> previous page </a >|</li>';} if ($ _ page ==$ _ pageabsolute) {echo '<li> next page | </li>'; echo '<li> last page </li> ';} else {echo '<li> <a href = "'. SCRIPT. '. php? Page = '. ($ _ page + 1 ). '"> next page </a> | </li>'; echo '<li> <a href = "'. SCRIPT. '. php? Page = '. $ _ pageabsolute. '"> last page </a> </li>';} echo '</ul>'; echo '</div> ';}}
Wrap the above Code glob. funic. php In the core function library
Then, you only need to call the following functions in the file:
<? Php}
// _ Pageing function call page, 1 | 2, 1 indicates the number page, 2 indicates the text page
_ Paging (2 );
?>