-- 没测试 提供一个思路,子查询。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 = ?
select a.hitnum as '点击数',(select count(*) from bg_filecomment where fileid=a.id) as '评论数' from bg_article as a where a.id=?
$sql = "select * from class";
$rst=mysql_query($sql,$conn);
$dbnum=mysql_num_rows($rst);这个就是这个查询下得总条数了至于点击数,需要做个表,id clicks,进来一次clicks+1,到时查询clicks数值就可以了
我的renum还没有插入数据
$rst=mysql_query($sql,$conn);
$dbnum=mysql_num_rows($rst);这样就可以了。
文章表:id text留言表:id text tid这个tid就是哪篇文章的id 比如数值是5 ,那这个留言就是文章表中id为5的那篇文章下的。我们只需要where tid=5就可以查询5号文章的所有留言。
-- 没测试 提供一个思路,子查询。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 = ?
select a.hitnum as '点击数',(select count(*) from bg_filecomment where fileid=a.id) as '评论数' from bg_article as a where a.id=?