frijole Posted January 30, 2008 Share Posted January 30, 2008 I am trying to figure out how to set up a DB for comments as well as replies to those comments. I am stuck on the replying part. any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/88579-solved-comments-and-replies/ Share on other sites More sharing options...
rhodesa Posted January 30, 2008 Share Posted January 30, 2008 You should be able to use the same table, just have a parent_id column. So any row "WHERE parent_id IS NULL" would be an original comment, and then you can "SELECT .. WHERE parent_id = '$id'" for the replies. This also allows you to have replies to replies. Quote Link to comment https://forums.phpfreaks.com/topic/88579-solved-comments-and-replies/#findComment-453504 Share on other sites More sharing options...
Daniel0 Posted January 30, 2008 Share Posted January 30, 2008 You could also use the modified preorder tree traversal algorithm. Here are some resources which should help you: http://www.sitepoint.com/article/hierarchical-data-database http://dev.mysql.com/tech-resources/articles/hierarchical-data.html Quote Link to comment https://forums.phpfreaks.com/topic/88579-solved-comments-and-replies/#findComment-453509 Share on other sites More sharing options...
frijole Posted January 30, 2008 Author Share Posted January 30, 2008 thanks for the responses, that makes sense now. the answers seem so obvious once you hear them. Quote Link to comment https://forums.phpfreaks.com/topic/88579-solved-comments-and-replies/#findComment-453943 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.