PHP paging function, the best paging function. PHP paging function backup, date, fixed several issues. (1) when the total number of pages is 0, there is an extra computing problem. (2) The calculation error occurs when the current page is the last page. PHP paging function backup, date, fixed several issues.
(1) when the total number of pages is 0, there is an extra computing problem.
(2) The calculation error occurs when the current page is the last page.
(3) problems when the total number of pages is small and the number of floating pages is large.
View plain
// New paging function
Function fenye ($ fenyeurl, $ page, $ totalnum, $ perpage, $ rewrite = 0 ){
$ Page = max ($ page, 1 );
$ Totalpage = ceil ($ totalnum/$ perpage );
$ Rangepage = 6;
$ Startpage = max (1, $ page-$ rangepage );
$ Endpage = min ($ totalpage, $ startpage + $ rangepage * 2-1 );
$ Startpage = min ($ startpage, $ endpage-$ rangepage * 2 + 1 );
If ($ startpage <1) $ startpage = 1;
$ Fileext = $ rewrite? '.Html ':'';
$ Html ='
';
$ Html. ='
- Homepage
';
$ Html. = $ page> 1? '
- Previous Page
':'';
For ($ I = $ startpage; $ I <= $ endpage; $ I ++ ){
$ Html. ='
- '. $ I .'
';
If ($ I = $ totalpage) break;
}
$ Html. = $ page <$ totalpage? '
- Next page
':'';
$ Html. ='
- Last page
';
$ Html. ='
';
Return $ html;
}
Author: "default7"
Bytes. (1) when the total number of pages is 0, there is an extra computing problem. (2) The calculation error occurs when the current page is the last page ....