Paging refers to the number of equal pages for the total records that meet the conditions except the records displayed on each page. The principle is quite simple. The formula is $ totalceil ($ toalRecord $ perpageNum ); paging refers to the number of equal pages except the records displayed on each page based on the total records that meet the conditions. The principle is quite simple. The formula is $ total = ceil ($ toalRecord/$ perpageNum );
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;
}
Paging Code 2
// Pagination, {total number of records, number of records displayed per page, current page, maximum number of pages displayed, pagination url}
Function page ($ toalrecord, $ perpagenum, $ curpage, $ url ){
$ Total = ceil ($ toalrecord/$ perpagenum );
$ Pagearr = array_slice (range (1, $ total), max (0, $ curpage -~~ ($ Perpagenum/2), $ perpagenum );
If ($ pagearr [0]! = 1 ){
Array_unshift ($ pagearr, sprintf ("<", $ pagearr [0]-1 ));
}
If ($ pagearr [count ($ pagearr)-1]! = $ Total ){
Array_push ($ pagearr, sprintf (">", $ pagearr [count ($ pagearr)-1] + 1 ));
}
Foreach ($ pagearr as $ I =>&$ v ){
$ V = is_numeric ($ v )? "{$ V}": $ v;
}
Return "Homepage". implode ('', $ pagearr)." Last page ";
}
Call
Page (99/* Total records */, 9/* number of entries per page */, page/* Current page, starting from 1 */, 'HTTP: // www.111cn.net /? Page = '/* url prefix */);