php爱好者们都会很喜欢各种各样的面向对象源码,调用方面一耗即用,哈分页数据显示,只不过针对于小的功能模块儿 那么不多说了 直接上源码,
n年以后的今天 小寒还是发现 没有注释代码的好习惯,唉 这个方面很有欠缺,在做php教程的同时是很有欠缺的 不过依然还是上源码来解释了
class page{
private $pagesize;
private $page;
private $total;
private $conn;
private $pagecount;
public function __construct($pagesize,$page){
$this->pagesize = $pagesize;
$this->page = $page;
}
public function listinfo(){
if ($this->page = ""||!is_numeric($this->page)){
$this->page = 1;//赋初值的过程
}
$this->conn = mysql_connect("localhost","root","");
mysql_select_db("user",$this->conn);
mysql_query("set names utf8");
$sql = mysql_query("select count(*) as total from user_student",$this->conn);
$info = mysql_fetch_array($sql);
if ($this->total == 0){
echo "暂无内容";
}else {
if ($this->total%$this->page == 0){
$this->pagecount = intval($this->total/$this->pagesize);
}else {
if ($this->total<=$this->pagesize){
$this->pagecount = 1;
}else {
$this->pagecount = ceil($this->total/$this->pagesize);
}
}
}
}
}
?>
以上就是php面向对象分页数据显示的内容,更多相关内容请关注PHP中文网(www.php.cn)!