首页  >  文章  >  php教程  >  php面向对象分页数据显示

php面向对象分页数据显示

黄舟
黄舟原创
2016-12-20 11:18:031356浏览

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)! 


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn