PHP+mysql     留言系统:  留言表comments:     id  content 
                          回复留言表 reply_comments: id  fid  content
怎么样把留言表,回复留言表显示在同一个网页中?忘知道的网友解惑一下。。

解决方案 »

  1.   

    select id, 0 as pid, content from comments
     union
      select pid , id, contents from reply_comments
     order by id desc, pid=0 desc;
      

  2.   

    //我自己的方法。不知道对你有用不 没什么经验。$sql = "SELECT * FORM comments";
    $query = mysql_query($sql) or die(mysql_error());
    while($row = mysql_fetch_array($query)){
    $id = $row['id'];
    $content = $row['content'];
    echo "留言:$content";
    $sqlr = "SELECT content FORM reply_comments WHERE fid = $id and content <>''";
    $queryr = mysql_query($sqlr) or die(mysql_error());
    $rowr = mysql_fetch_array($queryr);
    $contentr = $rowr['content'];
    echo "回复:$contentr";
    }
      

  3.   

    做两个SQL查询,用SMARTY把VAR都ASSIGN到一个HTML中去,但是回复表里的ID要和留言表的ID要做一个关联,然后在提交查询那里,用隐藏域接受一下留言表的ID,这样点回复的时候就是针对该条ID的留言