Php simple paging class .? Php *** paging class ** 2011831 * kcj ** classPage {private $ total; query the total data record private $ page; current page private $ pagesize; number of lines displayed per page priv /**
* Paging class
* 2011/8/31
* Kcj
**/
Class Page {
Private $ total; // query the total data records
Private $ page; // current page
// Private $ pagesize; // Number of Entries displayed on each page
Private $ pagenum; // total number of pages
Private $ num; // number of records per page
Private $ offset; // number of start offsets of records retrieved from the database
Function _ construct ($ total, $ page = 1, $ num = 5 ){
$ This-> total = $ total;
$ This-> page = $ page;
$ This-> num = $ num;
$ This-> pagenum = $ this-> getPageNum ();
$ This-> offset = $ this-> getOffset ();
}
Private function getPageNum (){
Return ceil ($ this-> total/$ this-> num );
}
Private function getNextPage () {// Next page
If ($ this-> page ==$ this-> pagenum ){
Return false;
} Else {
Return $ this-> page + 1;
}
}
Private function getPrevPage (){
If ($ this-> page = 1) {// Previous page
Return false;
} Else {
Return $ this-> page-1;
}
}
Private function getOffset (){
Return ($ this-> page-1) * $ this-> num;
}
Private function getStartNum (){
If ($ this-> total = 0 ){
Return 0;
} Else {
Return $ this-> offset + 1;
}
}
Private function getEndNum (){
Return min ($ this-> offset + $ this-> num, $ this-> total );
}
Public function getPageInfo (){
$ PageInfo = array (
"Row_total" => $ this-> total,
"Row_num" => $ this-> num,
"Page_num" => $ this-> getPageNum (),
"Current_page" => $ this-> page,
"Row_offset" => $ this-> getOffset (),
"Next_page" => $ this-> getNextPage (),
"Prev_page" => $ this-> getPrevPage (),
"Page_start" => $ this-> getStartNum (),
"Page_end" => $ this-> getEndNum ()
);
Return $ pageInfo;
}
}
?>
From chaojie2009
Http://www.bkjia.com/PHPjc/478369.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478369.htmlTechArticle? Php/*** paging class * 2011/8/31 * kcj **/class Page {private $ total; // query the total data record private $ page; // Current page/private $ pagesize; // The number of entries displayed per page priv...