Hello,

I'm trying to work out how to do some simple comment threading using PHP. I've overridden the blockquote tag in CSS so that it only indents from the left.

At the moment comments are simply displayed in reverse chronological order as all the replies to a particular post.

I just can't get my head around how to do the threading.

I could add an extra column in the comments table, i.e, "repliedto" which would contain the comment ID of the comment the user replied to, but that would seem to require some sort of recursion to check whether or not a comment has a reply, which I'd rather avoid if I can (mainly because I don't think I'm good enough to pull it off)

The other idea would be to have a threadID.. hmm...

table thread: threadID, rootCommmentID, replyCommentID

Then perhaps every time a user replies to a comment, it adds a row to the database?

How can I somehow take the data in the comments and/or thread table and sort an array of comment data which I can then use to layout the page, i.e, adding a different level of indent for each "thread"?

ie:

originalpost
-comment1/thread1(reply to post)

--comment2/thread2(reply to comment1)

---comment3/thread3(reply to comment 2)

----comment3/thread4(reply to comment 3)

--comment5/thread1(reply to comment1)

---comment3/thread5(reply to comment 2)

--comment6/thread2(reply to comment1)

-coment7/thread1(reply to post)

Thanks for any help/examples. I really just can't get my head around it.

Beth Gore
--
http://bethanoia.dyndns.org


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to