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; Link to comment https://forums.phpfreaks.com/topic/59554-count-total-records/ Share on other sites More sharing options...
teng84 Posted July 12, 2007 Share Posted July 12, 2007 use count(your field want to count) Link to comment https://forums.phpfreaks.com/topic/59554-count-total-records/#findComment-295925 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'; Link to comment https://forums.phpfreaks.com/topic/59554-count-total-records/#findComment-295928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.