Ec (2); functionoutPege ($ ps tutorial, $ page) {$ ps Total Information $ page Current page quantity $ max list max $ min list min $ max & nbsp; & nbsp; ($ page & gt; 5 )? $ Page + 5:10; if ($ max & gt; $ ps) $ max $ ps; $ min & nbsp; & script ec (2); script
Function outPege ($ PS tutorial, $ page)
{
// $ Ps cumulative information $ current page number of page $ max maximum number of list $ min minimum value of list
$ Max = ($ page> = 5 )? $ Page + 5: 10;
If ($ max> $ ps) $ max = $ ps;
$ Min = ($ page-5 );
If ($ min <1) $ min = 1;
If ($ page> 1) $ pagelist = "Homepage ";
For ($ I = $ min; $ I <= $ max; $ I ++ ){
$ Pagelist. = ($ I! = $ Page )? "{$ I}": "{$ page }";
}
$ Pagelist. = ($ page >=$ ps )? '':" Last page ";
Return $ pagelist;
}
// Method 2
/**
* Display paging Function
* Total number of records, current page number of currentpage, number of records on each page of rows, and length of the listpage page number list.
*/
Function showpage ($ records, $ currentpage, $ rows = 20, $ listpages = 7 ){
If ($ records <1) return '';
If ($ rows <1) $ rows = 20;
If ($ listpages <3) $ listpages = 7;
$ Action = $ _ SERVER ['query _ string']; // get the address bar? Post content
If ($ action) {// remove the content of page =...
$ Action = preg_replace ("/& page [^ &] */", "", $ action );
$ Action = preg_replace ("/page [^ &] * & */", "", $ action );
}
If ($ action) $ action. = '&';
$ Maxpage = ceil ($ records/$ rows); // obtain the maximum number of pages by performing an integer operation.
$ Middlepage = floor ($ listpages/2); // trim to get half of the page number to be displayed.
If ($ currentpage <1 | $ currentpage> $ maxpage) $ currentpage = 1;
$ Startpage = $ currentpage-$ middlepage;
If ($ maxpage-$ currentpage <= $ middlepage) $ startpage = $ maxpage-$ listpages;
If ($ startpage <2) $ startpage = 2; // The start page is calculated successfully.
$ Endpage = $ startpage + $ listpages;
If ($ endpage> $ maxpage) $ endpage = $ maxpage; // the calculation of the end page is complete.
If ($ currentpage! = 1 ){
$ Pagestr = "1 ";
} Else {
$ Pagestr = "1 ";
}
Homepage 1 2 3 4 5 6 7 8 last page