I've written a multi-threaded message board script, but i'm currently attempting to modify it so it looks like a linear message board, so it's much simpler to navigate. I basically want to know how how to COUNT(*) the replies to a post, and the replies to each reply, ect...
I'm not sure how this can be accomplised. My boards table is structured like:
+-----------+------------------+------+-----+---------------------+
| Field | Type | Null | Key | Default |
+-----------+------------------+------+-----+---------------------+
| topic_id | int(10) unsigned | YES | | NULL |
| post_id | int(10) unsigned | | PRI | NULL |
| parent_id | int(10) unsigned | | | 0 |
| subject | tinytext | | | |
| author | int(11) | | | 0 |
| date | datetime | | | 0000-00-00 00:00:00 |
| message | text | | | |
+-----------+------------------+------+-----+---------------------+
topic_id shouldn't be needed, as i'm using it to tell me which message board the post is on.
post_id is the unique ID of each post
parent_id is the post's parent post in the thread
subject is the post subject
author is an ID number to a specific member in a different table
date is when the message was posted
message is the post content.
I currently am using a COUNT(*) to get the number of replies to a specific thread, but It only returns the number of replies to it, and i want it to give me the number of replies in it's entire thread.