Answer the question
In order to leave comments, you need to log in
How to implement replies to comments?
The site has a comment system.
It is necessary to implement the ability to reply to a comment similar to that used on a toaster, for example:
@my_user_name, comment text...
Only here there is no unique username on the site, but there are ordinary names and id.
Ivan, the text of the comment...
How can this be implemented in the interface and how to arrange it in the database?
I suppose you need to add a hidden field for the id of the user who is being answered, and when you click the answer button under the comment, fill in this field, and add a name at the beginning of the comment. In the database, add a for column to store this id.
Answer the question
In order to leave comments, you need to log in
Add to comments parent_id
null - first level comment.
Or enter the ID of the parent comment if this is a response to some comment.
The classic tree structure is the same.
The user does not need to be pulled at all, well, except for the standard author_id or whatever it is with you.
I wrote in general.
A slightly different example, but the meaning is the same)
jsfiddle.net/cnr28/1
or like this: jsfiddle.net/cnr28/2
here 1 class for blocks, fewer selectors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question