I am using this code
$sql1 = mysql_query("SELECT section_id FROM forum_posts WHERE section_id='$sectionID' ");
$num_rows = mysql_num_rows($sql1);
to count the number of posts under specific category to show on the home page of the forum that how many posts are there in a particular section.
So is there a better option that to go through all the posts of that type. I think it will be a huge performance drain if I use this.
Edit 1: I just have to display the number of posts under each section in the forum so I want to check in the homepage how many topics each sections has as of now.
What will be the optimal mysql query for it.
Edit 2: Should I replace teh mysql_query function as stated in the phpmanual?
Just use count in sql itself.
If you want to get all section counts at the same time you can do it this way: