Ec (2); & lt ;? Php & nbsp; classMy_Lib_page {& nbsp; current page & nbsp; & nbsp; var $ page1; & nbsp; & nbsp script ec (2); script
Class My_Lib_page {
// Current page
Var $ page = 1;
// Number of entries per page
Var $ size = 20;
// Total number of records
Var $ count;
// Number of entries per column
Var $ lun = 10;
// Parameter binding
Var $ param;
// Jump
Var $ run;
// Name = admin & pwd = 2132 & sex = 1
// $ _ GET ['name'] = admin;
Private function setParam (){
$ Param = $ this-> param;
Unset ($ param ['page']);
If (is_array ($ param )&&! Empty ($ param )){
Foreach ($ param as $ key => $ value ){
$ Data [] = $ key. "/". $ value;
}
$ This-> url = implode ("/", $ data );
$ This-> param = $ this-> url;
$ This-> url = "/". $ this-> url;
} Else {
If (! Empty ($ param )){
$ This-> url = $ param;
$ This-> param = $ this-> url;
$ This-> url = "/". $ this-> url;
}
}
}
Function pageDate (){
$ This-> setParam ();
$ Num = ceil ($ this-> lun/2 );
$ This-> page = intval ($ this-> page );
$ This-> page = $ this-> page <= 0? 1: $ this-> page;
$ Cpage ['countpage'] = ceil ($ this-> count/$ this-> size); // total number of pages
$ Cpage ['page'] = $ this-> page> $ cpage ['countpage']? $ Cpage ['countpage']: $ this-> page;
// Current page
// Display the total number
$ Cpage ['lun '] = $ cpage ['countpage'] <$ this-> lun? $ Cpage ['countpage']: $ this-> lun;
// Start page number
$ Cpage ['start'] =$ this-> page> $ num-1? $ This-> page-$ num + 1: 1;
$ Cpage ['start'] = ($ cpage ['start'] + $ cpage ['lun ']) >=$ cpage ['countpage']? $ Cpage ['countpage']-$ cpage ['lun '] + 1: $ cpage ['start'];
// Display parameters
$ Cpage ['url'] = $ this-> url;
// Control redirection
$ Cpage ['run'] = $ this-> run? 1: 0;
$ Cpage ['param'] = is_array ($ this-> param )? '':"? ". $ This-> param;
Return $ cpage;
}
}
/* Include "../inc/smarty. php ";
$ Cp = new page;
Empty ($ _ REQUEST ['page']) | $ cp-> page = $ _ REQUEST ['page'];
$ Cp-> count = 70000;
$ Cp-> param = $ _ GET;
$ Cp-& gt; size = 100;
$ Cp-> lun = 7;
$ Cp-> run = true;
$ Data = $ cp-> pageDate ();
$ Smarty-> assign ("page", $ data );
$ Smarty-> display ("cpage.html ");
*/
?>