显示页面(index.php):<?php
include "conn.php" ;
include "Page.php" ;
$unhtml=new Page("select * from forum" , 3 , $_GET["pages"] , "公告" , "条") ;
echo "<p align=center><font color=green size=+3>论坛专题信息展示</font></p> ";
echo "<a href='addforum.html'><b>增加讨论话题</b></a></br>" ;
第13行:$arr=mysql_fetch_object($unhtml->query()) ;
do{
?>
<table cellpadding=0 cellspacing=0 border=0 align=center>
<tr>
<td><a href="talkshow.php?talkid=<?php echo $arr->talkid ; ?>" >讨论主题</a>&nbsp;&nbsp;<?php echo $arr->talktitle ; ?>&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;<a href="search.php?talkid=<?php echo $arr->talkid ; ?>" >搜索</a></td>
<td>&nbsp;&nbsp;<a href="forupdate.php?talkid=<?php echo $arr->talkid ; ?>" >编辑</a></td>
</tr>
<tr>
<td>讨论内容&nbsp;&nbsp;</td>
<td><?php echo $arr->talkcontent ; ?>&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;<a href="fordelete.php?talkid=<?php echo $arr->talkid ; ?>" >删除</a></td>
</tr>
</table>
<hr width="50%" color="red">
<?php
第30行: }while($arr=mysql_fetch_object($unhtml->query())) ;
?>
<table cellpadding=0 cellspacing=0 border=0 align=right>
<tr>
<td colspan=3 align=right><?php echo $unhtml->show() ; ?></td>
</tr>
</table>
<?php
mysql_close($conn) ;
?>分页Page.php代码:<?php
class Page{
var $sql ;
var $pages ;
var $pageSize ;
var $totalPage ;
var $amount ;
var $content ;
var $utits ;
function  __construct($sql , $pageSize , $pages , $content , $utits){
$this->sql=$sql ;
$this->pages=$pages ;
$this->content=$content ;
$this->utits=$utits ;
$this->pageSize=$pageSize ;
if(!isset($this->pages) || $this->pages=="" || $this->pages==0){
$this->pages = 1 ;
}
else{
$this->pages=$this->pages ;
}
第28行: $this->amount=mysql_result(mysql_query("select count(*) as amount from forum order by id desc") , 0 , "amount") ;
if($this->amount==0){
return false ;
}
else{
if(($this->amount % $this->pageSize)==0){
$this->totalPage=intval($this->amount / $this->pageSize) ;
}
else if($this->amount <= $this->pageSize){
$this->totalPage=1 ;
}
else{
$this->totalPage=ceil($this->amount / $this->pageSize) ;
}
}
}
function query(){
$mysql=mysql_query($this->sql . "limit" . ($this->pages - 1) * $this->pageSize . ", $this->pageSize") ;
return $mysql ;
}    function show(){
$string .="共有" . $this->content . "&nbsp;" . $this->amount . "&nbsp;" . $this->utits . "&nbsp;&nbsp;每页显示&nbsp;" . $this->pageSize . "&nbsp;" . $this->utits . "&nbsp;&nbsp;&nbsp;第&nbsp;" . $this->pages . "&nbsp;页/共&nbsp;" . $this->totalPage . "&nbsp;页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" ; $string .= "<a href=" . $_SERVER['PHP_SELF'] . "?page=1>&nbsp;首页&nbsp;</a>" ;
$string .="&nbsp;&nbsp;" ; if(($this->pages - 1) <=0){
$string .= "<a href=" . $_SERVER['PHP_SELF'] . "?page=1>&nbsp;上一页&nbsp;</a>" ;
}
else{
$string .= "<a href=" . $_SERVER['PHP_SELF'] . "?page=" .($this->pages - 1). ">&nbsp;上一页&nbsp;</a>" ;
} if(($this->pages + 1) >=$this->totalPage){
$string .= "<a href=" . $_SERVER['PHP_SELF'] . "?page=".$this->totalPage.">&nbsp;下一页&nbsp;</a>" ;
}
else{
$string .= "<a href=" . $_SERVER['PHP_SELF'] . "?page=" .($this->pages + 1). ">&nbsp;下一页&nbsp;</a>" ;
} $string .= "<a href=" . $_SERVER['PHP_SELF'] . "?page=" .$this->totalPage. ">&nbsp;尾页&nbsp;</a>" ;
return $string ;
}
}
?>出现的问题:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in D:\www\zwt\forum\Page.php on line 28论坛专题信息展示增加讨论话题Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in D:\www\zwt\forum\index.php on line 13
讨论主题        搜索   编辑 
讨论内容        删除 --------------------------------------------------------------------------------Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in D:\www\zwt\forum\index.php on line 30
共有公告  条  每页显示 3 条   第 1 页/共  页      首页    上一页  下一页  尾页  

解决方案 »

  1.   

    $unhtml=new Page("select * from forum" , 3 , $_GET["pages"] , "公告" , "条") ;
    echo $unhtml;   //贴出结果function query(){
    $mysql=mysql_query($this->sql . " limit " . ($this->pages - 1) * $this->pageSize . ", $this->pageSize") ;
    return $mysql ;
    }
      

  2.   


     mysql_connect("localhost", "mysql_user", "mysql_password") or
            die("Could not connect: " . mysql_error());
        mysql_select_db("mydb");    $result = mysql_query("SELECT id, name FROM mytable");    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
            printf ("ID: %s  Name: %s", $row[0], $row[1]);
        }    mysql_free_result($result);
      

  3.   

    在这里先谢谢各位了,但是两位的回答啊!好像...第二位的回答,我在我的conn.php中,已经配置好了,但是问题哈!
      

  4.   

    在 page.php 第28行前插入
    mysql_query("select count(*) as amount from forum order by id desc") or die(mysql_error());
    贴出结果