Php development requires paging code. During development, this paging function is indispensable. today we will share a very practical and simple php paging function implementation code. if you need it, please refer to it. Code, for example, in development, this paging function must be indispensable. today we will share a very practical and simple php paging function implementation code. if you need it, please refer to it.
| The code is as follows: |
|
/**
* Paging functions
*
* @ Param int $ count total number of entries
* @ Param int $ perlogs number of entries displayed per page
* @ Param int $ page current page number
* @ Param string $ url address of the page number
*/
Function pagination ($ count, $ perlogs, $ page, $ url, $ anchor = ''){
$ Pnums = @ ceil ($ count/$ perlogs );
$ Re = '';
$ UrlHome = preg_replace ("| [? &/] [^ ./? & =] * Page [=/-] | "," ", $ url );
For ($ I = $ page-5; $ I <= $ page + 5 & $ I <= $ pnums; $ I ++ ){
If ($ I> 0 ){
If ($ I = $ page ){
$ Re. = "$ I ";
} Elseif ($ I = 1 ){
$ Re. = "$ I ";
} Else {
$ Re. = "$ I ";
}
}
}
If ($ page> 6) $ re = "«...$ Re ";
If ($ page + 5 <$ pnums) $ re. ="...»";
If ($ pnums <= 1) $ re = '';
Return $ re;
} |
Bytes. Code such...