dennismonsewicz Posted April 2, 2009 Share Posted April 2, 2009 I have wrote my own backend to my personal website and am looking to see how to count how many posts are in a particular section (or subject). Code: $query = mysql_query("SELECT * FROM sections")or die(mysql_error()); while($row = mysql_fetch_object($query)) { echo '<p>'; echo '<a href="cat.php?action=view&catid=' . $row->section_id . '" class="blogpost"><img src="images/arrow.gif" alt="arrow"/>' . ucwords($row->sections) . '</a>'; echo '</p>'; } Quote Link to comment Share on other sites More sharing options...
premiso Posted April 2, 2009 Share Posted April 2, 2009 Post your table structure. This should also of been posted in the MySQL Help section, as an FYI. Quote Link to comment Share on other sites More sharing options...
dgoosens Posted April 2, 2009 Share Posted April 2, 2009 just use COUNT in your SQL statement SELECT COUNT(*) FROM sections Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted April 2, 2009 Author Share Posted April 2, 2009 I was able to accomplish what I needed using mysql_num_rows 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.