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

[eluser]Freakish_05[/eluser]
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.

Regards,
Freakish_05
#2

[eluser]deviant[/eluser]
The SQL query I was using for counting comments on news items was something along the lines of

Code:
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
#3

[eluser]Freakish_05[/eluser]
Thanks for that deviant!

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

Freakish_05




Theme © iAndrew 2016 - Forum software by © MyBB