为什么我的PHP翻页不能翻到下一页呀??求教
我定义了一个类来输出的 下面是类属性...最后是搜索页
include("script/conn.php");<br /> class Page{<br /> private $page; //当前页码<br /> private $page_num; //数据总共分多少页显示<br /> private $page_size; //每页显示的数据条数<br /> private $sql; //查询的SQL语句<br /> private $limit; //查询语句后面的limit控制语句<br /> private $total_Num; //总记录数<br /> public function __construct($sql='',$page_size=3){<br /> $result = mysql_query($sql);<br /> $this->total_Num = mysql_num_rows($result);<br /> $this->page_size = $page_size;<br /> $this->page_num = ceil($this->total_Num / $page_size); //计算总页数<br /> $this->sql = $sql;<br /> $temp = (isset($_GET["page"]) ? $_GET["page"] : 1); //获取当前页数<br /> $this->setpage($temp);<br /> $this->showpage();<br /> $this->showFoot();<br /> }<br /> private function showpage(){<br /> $this->limit = " LIMIT ".(($this->page - 1)* $this->page_size).",".$this->page_size; //limit语句<br /> $result = mysql_query($this->sql.$this->limit);<br /> if (!$result){ //判断结果是否存在<br /> if ($this->page_num > 0){ //如果不存在且页数大于0<br /> echo "查询出错"."<br>";<br /> }else{<br /> echo "无数据"."<br>";<br /> }<br /> return;<br /> }<br /> $cols = mysql_num_rows($result);<br /> while($row = mysql_fetch_array($result)){<br /> echo "<img src=".$row['Image']." / alt="为什么小弟我的PHP翻页不能翻到下一页呀?求教" >";<br /> echo "<br/>";<br /> }<br /> }<br /> private function setpage($page){<br /> if($page < 1){<br /> $page = 1;<br /> }<br /> else if($page > $this->page_num){<br /> $page = $this->page_num;<br /> }<br /> $this->page = $page;<br /> }<br /> private function showFoot(){<br /> echo "<br/>";<br /> echo "<a href='?page=1'>首页</a>丨";<br /> echo "<a href='?page=".($this->page - 1)."'>上一页</a>丨";<br /> echo "<a href='?page=".($this->page + 1)."'>下一页</a>丨";<br /> echo "<a href='?page=".$this->page_num."'>尾页</a>丨";<br /> echo "共有".$this->page_num."页丨";<br /> echo "当前第".$this->page."页";<br /> }<br /> }
class Page{<br /> private $page; //当前页码<br /> private $page_num; //数据总共分多少页显示<br /> private $page_size; //每页显示的数据条数<br /> private $sql; //查询的SQL语句<br /> private $total_Num; //总记录数<br /><br /> public $limit; //查询语句后面的limit控制语句<br /><br /> public function __construct($total=100, $page_size=3){<br /> $this->total_Num = $total;<br /> $this->page_size = $page_size;<br /> $this->page_num = ceil($this->total_Num / $page_size); //计算总页数<br /> $temp = (isset($_GET["page"]) ? $_GET["page"] : 1); //获取当前页数<br /> $this->setpage($temp);<br /> $this->showpage();<br /> $this->showFoot();<br /> }<br /> private function showpage(){<br /> $this->limit = " LIMIT ".(($this->page - 1)* $this->page_size).",".$this->page_size; //limit语句<br /> }<br /> private function setpage($page){<br /> if($page < 1){<br /> $page = 1;<br /> }else if($page > $this->page_num){<br /> $page = $this->page_num;<br /> }<br /> $this->page = $page;<br /> }<br /> private function showFoot(){<br /> echo "<br/>";<br /> echo "<a href='?page=1'>首页</a>丨";<br /> echo "<a href='?page=".($this->page - 1)."'>上一页</a>丨";<br /> echo "<a href='?page=".($this->page + 1)."'>下一页</a>丨";<br /> echo "<a href='?page=".$this->page_num."'>尾页</a>丨";<br /> echo "共有".$this->page_num."页丨";<br /> echo "当前第".$this->page."页";<br /> }<br />}