url = $url;
$this->pagesize = $pagesize;
$this->sql = $sql;
$this->getpage = $_get[page];
if(!$this->getpage) {
$this->getpage=1;
}
}
//取记录总数
function getcount() {
return mysql_num_rows(mysql_query($this->sql));
}
//格式化sql语句
function pagesql() {
$nowpage = $this->getpage;
$limitnumber= $this->pagesize;
if($nowpage $nowpage=1;
}
return $this->sql. limit .($nowpage-1)*$limitnumber.,.$limitnumber;
}
//显示分页,参数:显示数字链接个数,开始步进的页
function show($page = 5,$offset = 2){
$mpurl = $this->url;
$curr_page = $this->getpage;
$perpage = $this->pagesize;
$num=$this->getcount();//总记录数
$multipage = ;
if ($num > $perpage){
$pages = ceil($num / $perpage);
$from = $curr_page - $offset;
$to = $curr_page + $page - $offset - 1;
if ($page > $pages){
$from = 1;
$to = $pages;
}else{
if ($from $to = $curr_page + 1-$from;
$from = 1;
if (($to - $from) $to = $page;
}
}elseif ($to > $pages){
$from = $curr_page - $pages + $to;
$to = $pages;
if (($to - $from) $from = $pages - $page + 1;
}
}
}
$multipage .=
;
$multipage .=
;
$multipage .= .$num. \n;
$multipage .= .$curr_page./.$pages. \n;
if ($curr_page - $offset > 1){
$multipage .= «\n;
}
for ($i = $from; $i if ($i != $curr_page){
$multipage .= .$i.\n;
}else{
$multipage .= .$i.\n;
}
}
if ($curr_page + $offset $multipage .= »\n;
}
$multipage .= \n;
//$multipage .= .$perpage.条/页\n;
$multipage .=
;
}
return $multipage;
}
}
?>