FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP page turning problem





takashiro
It can't turn pages. What's wrong?
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>&nbsp";
$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/>";
}
?>
rohan2kool
takashiro wrote:
It can't turn pages. What's wrong?


You can't really expect anybody to go through all that when you won't even take the pain of explaining what the problem is, and background details on it. 'It can't turn pages' is a very very vague statement, because the term 'turning pages', is specific to the development environment u r using or have created.
Related topics
PHP homepage recreation problem
PHP Page
Problem with PHP
help - download pop up on php page
how do i make a window/iframe in a table within php page..??
php page flickering, maybe caused by flash item
PHP Form Sending problem
PHP and cookies. Simple problem.
PHP Whos Online Code OR Page refresh..
How to make a php page act differently
PHP login script problem
PHP noob problem
PHP Form Processing Problem
[help]Mysql & php problem
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.