解决方案 »

  1.   

    这个简单获取总计就行了比如留言条,这是我常用的,因为狠灵活,可以适应多种情况。
     $sql = "select * from class";   
      $rst=mysql_query($sql,$conn);
    $dbnum=mysql_num_rows($rst);这个就是这个查询下得总条数了至于点击数,需要做个表,id clicks,进来一次clicks+1,到时查询clicks数值就可以了
      

  2.   

    #3
    我的renum还没有插入数据
      

  3.   

    select fileid, count(id) as total from bg_filecomment group by fileid
      

  4.   

    那你要做两个数据表,一个表文章的另外一个就是留言表  其中要有这样一个项存储对应的文章id   假如设为widsql变成 $sql = "select * from 留言表 where wid=文章id";
    $rst=mysql_query($sql,$conn);
    $dbnum=mysql_num_rows($rst);这样就可以了。
      

  5.   

    这个是数据表的设置问题了。首先至少你的哪条留言是哪个文章下的,这个一定要有,要不程序怎么知道你这个文章下面有多少条留言?比如我这样设:  
    文章表:id  text留言表:id  text  tid这个tid就是哪篇文章的id    比如数值是5 ,那这个留言就是文章表中id为5的那篇文章下的。我们只需要where tid=5就可以查询5号文章的所有留言。
      

  6.   

    你设置的renum如果是专门存储回复数,那就在回复的时候+1就可以了。那你就不用这么查询,只需要查出renum的值就行了。
      

  7.   


    -- 没测试 提供一个思路,子查询。select hitnum '点数数', t2.total '评论数'  from bg_article as t1, (select co    unt(*) as total from bg_filecomment where fileid = t1.id) as t2 where  t1.id     = ?
      

  8.   


    select a.hitnum as '点击数',(select count(*) from bg_filecomment where fileid=a.id) as '评论数' from bg_article as a where a.id=?