phpSensei Posted July 12, 2007 Share Posted July 12, 2007 I have a forum and its is almost finished... I am currently displaying the Total number of Topics within a Forum, but I dont know how. Each Topic is assigned to a Forum by inserting the Forum's id which is "ID", (located in forums table), and into a field named idforum, which is located in the topic_fr table. Now that idforum has the id of the forum it has been inserted into, I can display these in each forum. I have 2 forums, but I do not know how to display the total number of topics in each forum. I was thinking something like this, but no. $query = mysql_query("SELECT * FROM message_msg INNER JOIN forums ON idtop_msg=id WHERE idtop_msg='$id'"); $number=mysql_num_rows($query); echo $number; Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 12, 2007 Share Posted July 12, 2007 use count(your field want to count) Quote Link to comment Share on other sites More sharing options...
trq Posted July 12, 2007 Share Posted July 12, 2007 Maybe? SELECT COUNT(idforum) AS cnt FROM topic_fr WHERE idforum = '$id'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.