Jump to content

Comments with reply


Kingy

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.