The pagination effects of numbers and text in PHP self-training projects are implemented in functions ,. The pagination of numbers and text in PHP self-training projects is implemented in functions. ***** @ param $ _ SQL * @ param $ _ size * function_page ($ _ SQL, $ _ size) {retrieve all the variables in the PHP self-training project. the pagination effect of the numbers and text is implemented in the function,
/***** @ 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 _ paging ($ _ type) {global $ _ page, $ _ pageabsolute, $ _ num; if ($ _ type = 1) {echo''; Echo'
'; For ($ I = 0; $ I <$ _ pageabsolute; $ I ++) {if ($ _ page = ($ I + 1) {echo'
- $ I + 1). '"class =" selected ">'. ($ I + 1 ).'
';} Else {echo'
- $ I + 1). '">'. ($ I + 1 ).'
';} Echo'
'; Echo'
';} Elseif ($ _ type = 2) {echo'
'; Echo'
'; Echo'
- '. $ _ Page.'/'. $ _ pageabsolute.' page |
'; Echo'
- Total'. $ _ Num .'Members |
'; If ($ _ page = 1) {echo'
- Homepage |
'; Echo'
- Previous Page |
';} Else {echo'
- Homepage |
'; Echo'
- $ _ Page-1). '"> Previous page |
';} If ($ _ page ==$ _ pageabsolute) {echo'
- Next Page |
'; Echo'
- Last page
';} Else {echo'
- $ _ Page + 1). '"> Next page |
'; Echo'
- $ _ Pageabsolute. '"> Last Page
';} Echo'
'; Echo'
';}}
Wrap the above code glob. funic. php in the core function library
Then, you only need to call the following functions in the file:
// _ Pageing function call page, 1 | 2, 1 indicates the number page, 2 indicates the text page
_ Paging (2 );
?>
Response,/***** @ param $ _ SQL * @ param $ _ size */function _ page ($ _ SQL, $ _ size) {// retrieve all the variables...