Another php paging code. Another php paging code has previously written a lot of php paging classes. But today, I feel like this paging program is very good, simple and practical, and there is no redundant code for proper code, it is a good paging and php paging code that has previously been written in many php paging classes. But today, this paging program is very good, simple, and practical, the code is reasonable and there is no redundant code. it is a good paging function.
Another php Tutorial paging code
I have written a lot of php paging classes before, but today I feel like this paging program is very good, simple and practical, and there is no extra code for proper code. it is a good paging function.
*/
Class multipage {
Var $ total;
Var $ perpage;
Var $ pages;
Var $ maxpage;
Var $ offset = 9;
Var $ curr_page;
Function init ($ total, $ perpage, $ maxpage) {// initialize the page number
$ This-> total;
$ This-> perpage;
$ This-> maxpage;
$ This-> offset = 9;
}
Function getpagelist () {// retrieve the page List
$ Result_pages = "";
$ This-> pages = ceil ($ this-> total/$ this-> perpage );
If ($ this-> pages> $ this-> maxpage ){
$ From = $ this-> curr_page-$ this-> offset;
If ($ from <1 ){
$ From = 1;
}
$ To = $ from + $ this-> maxpage-1;
If ($ to> $ this-> pages ){
$ To = $ this-> pages;
If ($ to-$ from) <$ this-> maxpage ){
$ From = $ from-1;
}
}
} Else {
$ From = 1;
$ To = $ this-> pages;
}
$ P = 0;
For ($ I = $ from; $ I <= $ to; $ I ++ ){
$ Result_pages [$ p] = $ I;
$ P ++;
}
Return $ result_pages;
}
Function getfirst () {// get the first page
If ($ this-> curr_page> 1 & $ this-> pages> 1 ){
Return 1;
} Else {
Return "";
}
}
Function getlast () {// get the last page
If ($ this-> pages> 1 & $ this-> curr_page <$ this-> pages ){
Return $ this-> pages;
} Else {
Return "";
}
}
Function getprev () {// Previous Page
$ Prevpage = $ this-> curr_page-1;
If ($ prevpage> 0 ){
Return $ prevpage;
} Else {
$ Prevpage = "";
Return $ prevpage;
}
}
Function getnext () {// Next page
$ Nextpage = $ this-> curr_page + 1;
If ($ nextpage <= $ this-> pages ){
Return $ nextpage;
} Else {
$ Nextpage = "";
Return $ nextpage;
}
}
Function gettotal () {// total number of pages
If ($ this-> pages> 0 ){
Return $ this-> pages;
} Else {
Return 1;
}
}
}
// Usage of the paging class
$ Page = new multipage ();
$ Page-> gettotal (); //
$ Page-> getnext (); // Next page
Paging class, but today I feel like this paging program is very good, simple and practical, and there is no redundant code in the code. it is a good paging...