Welcome Guest, Not a member yet? Register   Sign In
Extenstion of blog tutorial -> Counting the Comments

Good morning everyone!

I've been trying to extend the blog video tutorial a bit by adding a count of the comments for a particular blog entry (i.e. "There are X comments")

I've been trying to add a count into my SQL query for all the comments where entry_id matches the blog id. This shows no sign of working :long:

Any suggestions on how I could accomplish this would be very much appreciated.


The SQL query I was using for counting comments on news items was something along the lines of

SELECT news.*, COUNT(comment.id) AS num_comments FROM news LEFT JOIN comment ON (comment.post_id=news.id) GROUP BY news.id ORDER BY news.date_posted DESC

Thanks for that deviant!

I cut your code a bit but it works great! Thanks so much!


Theme © iAndrew 2016 - Forum software by © MyBB