Possible Duplicate:
Display hierarchical data
I'm looking to create a nested comments system - I realise this has been covered before on SO and the net but I cant seem to get anything to work correctly.
Given the following table structure (which I have created):
CREATE TABLE IF NOT EXISTS `comments` (
`commentid` int(11) NOT NULL auto_increment,
`newsid` int(11) NOT NULL,
`body` text NOT NULL,
`added` int(11) NOT NULL,
`parent` int(11) default NULL,
PRIMARY KEY (`commentid`)
)
How am I able to the comments in a threaded manner? I'm looking for either a PHP solution of MySQL. I realise that parent holds the commentid (parent) of the comment.
When you save a reply, assign the parent id to the comment id of the one of which you are replying to.
When generating the HTML, recursively print the child comments of any parent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With