码迷,mamicode.com
首页 > 其他好文 > 详细

将上下页转换封装类

时间:2014-11-12 19:29:11      阅读:175      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!