Ok, new problem.
The 2 following queries seem to be interfering with each other. What happens is the first query is only for the top replies to a thread. The second query is for all posts in a thread (Threads + Replies). Sometimes, not always, the Top Poster (second query) will pick up the Top Relpies (first query) username. The other counts seem to stay correct. First, is there a way to combine the 2 and if not, how do I keep the username mix-up from happening?
PHP Code:
$topreplies = $db->query_first("
SELECT user.userid, user.username, COUNT(post.postid) AS replycount
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (post.userid = user.userid)
WHERE thread.forumid=$forumid AND thread.firstpostid != post.postid
GROUP BY post.userid
ORDER BY replycount DESC
LIMIT 1
");
$topposter = $db->query_first("
SELECT user.userid, user.username, COUNT(post.postid) AS postcount
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (post.userid = user.userid)
WHERE thread.forumid=$forumid
GROUP BY post.userid
ORDER BY postcount DESC
LIMIT 1
");