php愛好者們都會很喜歡各種各樣的物件導向源碼,調用方面一耗即用,哈分頁數據顯示,只不過針對於小的功能模組兒那麼不多說了直接上源碼,
n年以後的今天小寒還是發現沒有註解程式碼的好習慣,唉這個方面很有欠缺,在做php教程的同時是很有欠缺的不過依然還是上源碼來解釋了
class page{
private $pagesize;
private $page;
private $total;
private $conn;
private $pagecount;
public function __construct($pagesize,$page){
$this->pagesize = $pagesize; >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 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->totalpagesize){
$this->pagecount = 1;
}else {
$this->pagecount = ceil($this- >total/$this->pagesize);
}
}
}
}
}
?>
以上就是php物件導向分頁資料顯示的內容,更多相關內容請關注PHP中文網(www.php .cn)!