Unholy Prayer Posted March 6, 2007 Share Posted March 6, 2007 Ok, I'm making a forum software for my website and I want to put the number of replies for the listed forum. How would I count the number of rows of the replies table that are in the certain forum? Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 that depends on how your database is setup, but something like this may do the trick: <?php $sql = "SELECT * FROM your_table WHERE forum = '". $forumName ."'"; $query = mysql_query($sql); $numRows = mysql_num_rows($query); echo "Number of Replies: ". $numRows ."<br />\n"; ?> Quote Link to comment Share on other sites More sharing options...
Unholy Prayer Posted March 6, 2007 Author Share Posted March 6, 2007 That would only work for my count threads code which I already have working. This is my table structure: Forums Table: Threads Table(fid= forum the thread is in) Replies Table(tid=thread the reply is in) Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 so what exactly are you trying to do? Quote Link to comment Share on other sites More sharing options...
Unholy Prayer Posted March 7, 2007 Author Share Posted March 7, 2007 I am trying to count the number of replies that are in the forum being listed. Quote Link to comment Share on other sites More sharing options...
Snooble Posted March 7, 2007 Share Posted March 7, 2007 create a while loop of the sql db. add all the users' posts together and store. Or (from scratch) every time a post is stored ++ a variable/tablecell Snooble 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.