I looked for tutorials about this on the Internet, but basically no one said anything. Then one day I saw a PHP program that designed a database design diagram like this, and I gained a lot of insights! The following is the structure diagram of the database
Let’s continue the introduction
id This is considered the parent ID. You can use this ID to query whether there is a child ID under this ID. You can also record the ID of the message
son_id This is the child id and you can find the corresponding parent id through this id
news_id Record the id of the article
sender_author The person who accepted the message
receiver_author The person who sent the message
content The content of the message
status When someone replies to your post, the value changes from 0 to 1. When the message is no longer displayed, if you do not click in, the message still exists
time The time when the message was recorded
Message board reply ideas
When the sender (that is, the person who left a message) wants to leave a message or reply to the article, the receiver (that is, the author of the article or the person to be replied to) needs to receive it. If a single database statement queries the keys sender_author and receiver_author, you will know who the receiver is and who the sender is. Then display the reply content based on this judgment
Tips you have a new message idea
When the sender sends a message, the value of this status defaults to 0, which prompts the receiving and sending you to have a new message. When clicked in, the database modification statement is called to modify the specified value to 1 so that it will not be displayed.
Database operation statements when viewing comments
Message user:receiver_author;?> Message content:content?>
This shows how to get the specified parent ID and then display all the child IDs and message content in it
Here is the floor User:receiver_author;?>
Message content:content?>
sender_author == $row->receiver_author){ echo $row->sender_author;}
else{ echo $row->sender_author."Replied:".$row->receiver_author;}?>
The content is:content?>
http://www.bkjia.com/PHPjc/825293.html