<?php
Class my_lib_page{
Current page
var $page = 1;
Show number of bars per page
var $size = 20;
Total number of records
var $count;
Show number of bars 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 pages
$cpage [' page '] = $this->page > $cpage [' countpage ']? $cpage [' Countpage ']: $this->page;
Current page
Show totals
$cpage [' lun '] = $cpage [' countpage '] < $this->lun? $cpage [' Countpage ']: $this->lun;
//Start Page
$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 '];
//Parameter display
$ cpage[' url ' = $this->url;
Control jump
$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->size = 100;
$CP->lun = 7;
$CP->run = true;
$data = $CP->pagedate ();
$smarty->assign ("page", $data);
$smarty->display ("cpage.html");
*/