Kingy Posted February 9, 2010 Share Posted February 9, 2010 I have been asked to make a news script with comments. Now generally this is pretty easily done and I have done most of it. The problem I'm having is the person has asked me to add a reply link to all comments that are posted, and indent the replies and so on and so forth. For example: [Main news article] -Comment 1 - Reply 1 - Reply 2 - Reply 1 to Reply 2 - Reply 2 to Reply 2 -Comment 2 -Comment 3 - Reply 3 The problem is I can't seem to get my head around how the database should be mapped out. I'm sure there is probably a pretty simple solution but its just going right over the top of my head at the moment. Would anyone please be able to explain a possible way to solve this problem. Thanks Link to comment https://forums.phpfreaks.com/topic/191556-comments-with-reply/ Share on other sites More sharing options...
ohdang888 Posted February 9, 2010 Share Posted February 9, 2010 i would set it up like this... i'm not sure its the most effecient...but it should work. table "comments": articleID - id # of article page commentID - auto Increase...each row has a unique number isReplyTo - (either the commentID # or if it is a base comment (a comment on the article, not on another comment), simply 0) text - what they say and then whatever info you want Link to comment https://forums.phpfreaks.com/topic/191556-comments-with-reply/#findComment-1009772 Share on other sites More sharing options...
Kingy Posted February 9, 2010 Author Share Posted February 9, 2010 See that was what I was thinking, and that would be great for replies to the base comment, but what about a reply to a reply lol. Link to comment https://forums.phpfreaks.com/topic/191556-comments-with-reply/#findComment-1009780 Share on other sites More sharing options...
Hussam Posted February 10, 2010 Share Posted February 10, 2010 This way I think you better make a separate replies table like this: table: replies: id ---> the reply id itself, auto increment. base_comment_id ---> the id of the base comment. replyTo_id ---> has the id that it is a reply to it, or 0 if its a base comment. text ----> the reply's test I think this way you can have unlimited replies to each other and you can intend from VA to AK lol. I can't think more of it, its kinda confusing lol. Link to comment https://forums.phpfreaks.com/topic/191556-comments-with-reply/#findComment-1009805 Share on other sites More sharing options...
Kingy Posted February 10, 2010 Author Share Posted February 10, 2010 Thanks I think you're on to it. I'll give it a go. Thanks Link to comment https://forums.phpfreaks.com/topic/191556-comments-with-reply/#findComment-1009812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.