DATE_FORMAT(comments.date, '%M %D, %Y') as fdate,
COUNT(com_replies.rid) AS cou,
AVG(com_votes.vote) as avv
LEFT JOIN com_replies on com_replies.cid = comments.cid
LEFT JOIN com_votes on com_votes.cid = comments.cid
WHERE comments.id = '$id' and
comments.status = '1'
GROUP BY comments.cid
ORDER by avv desc, comments.date
So this SQL selects from 3 tables. A table of commments, a table of replies to comments, and a table of comment votes.
What I'm doing is building a list of comments along with the rating each comment has and a number of replies for the comment. Its very much like a forum.
Whats not working is the number of replies. If there is no replies it lists the number 0 correctly. If there is a reply it lists a random number.
To see this in action check out this page: http://www.online-literature.com/orwell/1984/
Anything with a reply gets a random number of replies listed.
Each comment at most has like 1 reply. I looked in the database, the random number is neither the ID of the reply or the number of the reply (in order).
So... I have no idea where the number is coming from or how it's getting it.