标签:http io ar sp div on art cti bs
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
class page{
var $table;
var $pagesize;
var $totalsize;
var $totalpage;
var $start;
var $page;
var $propage;
var $xiapage;
//var $div;
//var $data;
function __construct($table,$pagesize){
$this->table=$table;
$this->pagesize=$pagesize;
$sql="select * from ".$table."";
$query=mysql_query($sql);
$this->page=isset($_GET[‘page‘])?$_GET[‘page‘]:1;
$this->totalsize=mysql_num_rows($query);
$this->totalpage=ceil(($this->totalsize)/($this->pagesize));
$this->start=($this->pagesize)*($this->page-1);
$this->propage=$this->page-1;
$this->xiapage=$this->page+1;
}
function getrows(){
$sqls="select * from ".$this->table." limit ".$this->start.",".$this->pagesize."";
$querys=mysql_query($sqls);
$datas=array();
while($rows=mysql_fetch_array($querys)){
$datas[]=$rows;
}
//print_r($data);
//$this->data=$datas;
return $datas;
}
function getitem(){
if(($this->page)<=1){
$this->page=1;
}
if(($this->page)>($this->totalpage)){
$this->page=$this->totalpage;
}
$div="<a href=\"?page=1\"> 首页</a><a href=\"?page=$this->propage\"> 上一页</a><a href=\"?page=$this->xiapage\"> 下一页</a><a href=\"?page=$this->totalpage\">尾页</a>";
return $div;
}
}
?>
标签:http io ar sp div on art cti bs
原文地址:http://www.cnblogs.com/wan1011/p/4093262.html