PHP dynamic paging function, required for paging development in PHP
Source: Internet
Author: User
PHP dynamic paging function, which is essential for PHP development paging. In fact, this is a must-have. if you don't talk about it, the PHP dynamic paging function is still good. it's relatively simple to paste the code:
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;
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service