formasfunction Posted September 12, 2007 Share Posted September 12, 2007 I'm looking for a simple tutorial on how to create a comment section for a website that allows users to reply to previous comments, indenting them much in the same way a site like slashdot does. I have a working script for a simple list but I'm not sure how to write a recursive function to deal with the rest of it. I've done quite a few searches for previous solutions but I get the feeling I'm not using the right terms. Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/68969-comment-component-with-nested-replies/ Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 There are systems already done that do this. try googling "php slashdot style comments". but what you are looking for is HTML <table> alignment. Quote Link to comment https://forums.phpfreaks.com/topic/68969-comment-component-with-nested-replies/#findComment-346680 Share on other sites More sharing options...
formasfunction Posted September 12, 2007 Author Share Posted September 12, 2007 It's not the html or css formatting of the comments that I need help with, it's writing a function that correctly cycles through comment ids and identifies child comments, placing them in the correct order. Quote Link to comment https://forums.phpfreaks.com/topic/68969-comment-component-with-nested-replies/#findComment-346697 Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 well then I dont understand your question. I'm getting that you dont know how to code the indent section for the "comments", and that would be HTML/tables. the php part would handle how much the colspan would use Quote Link to comment https://forums.phpfreaks.com/topic/68969-comment-component-with-nested-replies/#findComment-346700 Share on other sites More sharing options...
formasfunction Posted September 12, 2007 Author Share Posted September 12, 2007 I'm not exactly sure how to write the actual recursive function that will take an array returned from a MySQL table named COMMENTS with the following columns: id comment parent_id timestamp Comments without a parent_id are top level and ordered by the timestamp. However, any comment with a parent_id will need to be ordered under the comment who's id matches the parent_id, secondarily by it's timestamp. A straight loop won't allow me to take the parent_id's into account. I'd like to do it all with just one hit to the database. Quote Link to comment https://forums.phpfreaks.com/topic/68969-comment-component-with-nested-replies/#findComment-347055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.