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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.