Dear Big Brother, I just learned the php + smarty template paging class. I don't know how to call it! [Color # FF0000] [color] paging class & lt ;? Php *************************************** **************************************** * & nbsp; * The brophp.com paging class can be called from my eldest brother and younger brother. I just learned the php + smarty template paging class. I don't know how to call it!
[Color = # FF0000] [/color] paging class
/*************************************** **************************************** *
* Brophp.com pagination class. you can customize the pagination content. *
**************************************** ****************************************
* License statement: a "learning" ultra-lightweight PHP framework designed for php readers and LAMP brothers. *
**************************************** ****************************************
* All rights reserved (C) 2011-2013 Beijing Yi diyou Education Consulting Ltd. *
* Website address: http://www.lampbrother.net (LAMP brother )*
**************************************** ****************************************
* $ Author: Gao Luofeng (skygao@lampbrother.net) $ *
* $ Date: 10:00:00 $ *
**************************************** ***************************************/
Class Page {
Private $ total; // The total number of records in the data table
Private $ listRows; // number of lines displayed per page
Private $ limit; // SQL statement using limit from name
Private $ uri; // url
Private $ pageNum; // Number of pages
// Display the content in the page information, which can be set by yourself
Private $ config = array ('head' => "record", "prev" => "previous page", "next" => "next page ", "first" => "homepage", "last" => "last ");
Private $ listNum = 10; // The number of display pages by default.
/**
* Constructor: you can set the attributes of the paging class.
* @ Paramint $ total calculate the total number of records on the page
* @ Paramint $ listRows (optional) number of records to be displayed on each page by default
* @ Paramstring $ pa (optional). it is used to pass parameters to the target page.
*/
Public function _ construct ($ total, $ listRows = 25, $ pa = ""){
$ This-> total = $ total;
$ This-> listRows = $ listRows;
$ This-> uri = $ this-> getUri ($ pa );
$ Page =! Empty ($ _ GET ["page"])? $ _ GET ["page"]: 1;
If ($ total> 0 ){
If (preg_match ('/\ D/', $ page )){
$ This-> page = 1;
} Else {
$ This-> page = $ page;
}
} Else {
$ This-> page = 0;
}
$ This-> pageNum = ceil ($ this-> total/$ this-> listRows );
$ This-> limit = $ this-> setLimit ();
}
/**
* This parameter is used to set the display page information for consistent operations.
* @ Paramstring $ param is the subscript of array config
* @ Paramstring $ value is used to set the element value corresponding to the config subscript.
* @ Returnobject returns the current object $ this
*/
Function set ($ param, $ value ){
If (array_key_exists ($ param, $ this-> config )){
$ This-> config [$ param] = $ value;
}
Return $ this;
}
Private function setLimit (){
If ($ this-> page> 0)
Return ($ this-> page-1) * $ this-> listRows. ", {$ this-> listRows }";
Else
Return 0;
}
Private function getUri ($ pa ){
If ($ pa = "")
Return $ GLOBALS ["url"]. $ _ GET ["a"]. '/';
Else
Return $ GLOBALS ["url"]. $ _ GET ["a"]. '/'. trim ($ pa ,"/").'/';
}
Private function _ get ($ args ){
If ($ args = "limit ")
Return $ this-> limit;
Else
Return null;
}
Private function start (){
If ($ this-> total = 0)
Return 0;
Else
Return ($ this-> page-1) * $ this-> listRows + 1;
}
Private function end (){
Return min ($ this-> page * $ this-> listRows, $ this-> total );
}
Private function firstprev (){
If ($ this-> page> 1 ){
$ Str = "uri} page/1' >{$ this-> config [" first "]}";
$ Str. = "uri} page/". ($ this-> page-1). "'>{$ this-> config [" prev "]}";
Return $ str;
}
}
Private function pageList (){
$ LinkPage ="
";