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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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.