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? Link to comment https://forums.phpfreaks.com/topic/41518-count-row-from-two-tables/ 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"; ?> Link to comment https://forums.phpfreaks.com/topic/41518-count-row-from-two-tables/#findComment-201134 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) Link to comment https://forums.phpfreaks.com/topic/41518-count-row-from-two-tables/#findComment-201149 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? Link to comment https://forums.phpfreaks.com/topic/41518-count-row-from-two-tables/#findComment-201207 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. Link to comment https://forums.phpfreaks.com/topic/41518-count-row-from-two-tables/#findComment-201721 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 Link to comment https://forums.phpfreaks.com/topic/41518-count-row-from-two-tables/#findComment-201728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.