It can't turn pages. What's wrong?
page.inc
test.php
page.inc
| Code: |
| <?php
class Page { var $MaxLine; var $MaxPage; var $Offset; var $Total; var $Result; var $TPages; var $CPages; var $Sql; var $PageQuery; var $OutPut; var $TextSize; var $TextColor; var $InBdrColor; var $InBgColor; function Page($SQL,$ML,$MP,$TS,$TC,$INBDRC,$INBGC){ $this->Sql=urldecode($SQL); $this->Sql=StripSlashes($this->Sql); $this->MaxLine=$ML; $this->MaxPage=$MP; $this->TextSize=$TS; $this->TextColor=$TC; $this->InBdrColor=$INBDRC; $this->InBgColor=$INBGC; } function SetPagePara($key,$value){ $tmp[key]=$key; $tmp[value]=$value; $this->PageQuery[]=$tmp; } function ShowList($startpage,$t,$OF,$PHP_SELF) { if ($OF=="") $OF=0; $this->Offset=$OF; $querysql=$this->Sql; if ($t==1) {$startpage=$startpage+$this->MaxPage;$this->Offset=($startpage-1)*$this->MaxLine;} if ($t==2) {$startpage=$startpage-$this->MaxPage;if ($startpage<1) {$startpage=1;}$this->Offset=($startpage-1)*$this->MaxLine;} if ($t==3) {$this->Offset=($startpage-1)*$this->MaxLine;} if ($startpage<1 or $startpage=="") $startpage=1; $result=mysql_query($querysql); $this->Total=mysql_num_rows($result); $sqllimit=" LIMIT ".$this->Offset." , ".$this->MaxLine; $this->Result=mysql_query($querysql.$sqllimit); $this->Tpages=ceil($this->Total/$this->MaxLine); $this->CPages=$this->Offset/$this->MaxLine+1; $querysql=urlencode($this->Sql); $this->OutPut="<form name=\"pageform\" action=$PHP_SELF?offset=$this->Offset&querysql=$querysql><font style=\"font-size:$this->TextSize;color:$this->TextColor\">共<b> ".$this->Tpages."</b> 页/第</font><input type=\"text\" name=\"startpage\" size=\"3\" maxlength=\"4\" value=\"".$this->CPages."\" style=\"border:$this->InBdrColor 1pt solid;background-color:$this->InBgColor;height:12pt;text-align: center;color:$this->TextColor\"><font style=\"font-size:$this->TextSize;color:$this->TextColor\">页</font> "; $this->OutPut.="<input type=\"hidden\" name=\"t\" value=3>"; $k=count($this->PageQuery); $strQuery=""; for($i=0;$i<$k;$i++){ $strQuery.="&".$this->PageQuery[$i][key]."=".$this->PageQuery[$i][value]; $this->OutPut.="<input type=\"hidden\" name=\"".$this->PageQuery[$i][key]."\" value=".$this->PageQuery[$i][value].">"; } if ($startpage>1) {$this->OutPut.="<font style=\"font-size:$this->TextSize;color:$this->TextColor\">[<a href=http://book.hackbase.com/7/$PHP_SELF?offset=$this->Offset&querysql=$querysql&startpage=$startpage&t=2$strQuery style=\"color:$this->TextColor;text-decoration:none\"><<</a>]</font>";} for ($i=$startpage;$i<=$this->Tpages;$i++){$offset=($i-1)*$this->MaxLine; $this->OutPut.="<font style=\"font-size:$this->TextSize;color:$this->TextColor\">[<a href=http://book.hackbase.com/7/$PHP_SELF?offset=$offset&querysql=$querysql&startpage=$startpage$strQuery style=\"color:$this->TextColor;text-decoration:none\">".$i."</a>] </font>"; if ($i-$startpage>$this->MaxPage-2 and $i!=$this->Tpages) {$this->OutPut.="<font style=\"font-size:$this->TextSize;color:$this->TextColor\">[<a href=http://book.hackbase.com/7/$PHP_SELF?offset=$this->Offset&querysql=$querysql&startpage=$startpage&t=1$strQuery style=\"color:$this->TextColor;text-decoration:none\">>></a>]</font>";break;}} $this->OutPut.="</form>"; } //******end class } ?> |
test.php
| Code: |
| <?
//include("include/ini_var.inc"); include("include/select_db.inc"); include("page.inc"); if ($querysql=="") $querysql=urlencode("select * from td_sh_goods"); $pclass=new Page($querysql,3,2,"10pt","blue","black","#aaaaaa"); $pclass->SetPagePara("para","paravalue"); $pclass->ShowList($startpage,$t,$offset,$PHP_SELF); echo $pclass->OutPut; while($date=mysql_fetch_row($pclass->Result)){ echo "$date[1] | $date[2] | $date[3]<br/>"; } ?> |
