Php simple message board and reply function implementation-PHP Tutorial

Source: Internet
Author: User
Tags php foreach
Php simple message board and reply function implementation. I found this tutorial on the Internet, but basically no one said anything. then one day I saw a PHP program designed a database design similar to this, and then I found a lot on the Internet. but basically no one said anything. then one day I saw a PHP program designed a database design similar to this, and I learned a lot! The following figure shows the structure of the database.

Next, let's continue with the introduction.

Id: this is 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 a child id, and the corresponding parent id can be found through this id.
News_id record the document id
Sender_author: the person who receives the message
Receiver_author: the person who sent the message
Content
Status when someone replies to your post, the value is changed from 0 to 1, and the message is not displayed. if you do not click in, the message still exists.
Time records the message time


Message board reply ideas

When the sender (the person who sends the message) wants to leave a message or reply to the post, the receiver (the author of the article or the person to be replied) is required to receive the message. If the single database statement finds the keys sender_author and receiver_author, it will know who the receiver is and who the sender is. Then the response content is displayed based on this judgment.


Prompt you to have a new message idea

When the sender sends a message, the default value of this status is 0, indicating that you receive a new message. When you click in, call the database modification statement to change the specified value to 1.

Database operation statement for viewing comments

The code is as follows:


Function message ($ id ){
$ Query = $ this-> db-> query ("SELECT * FROM message WHERE news_id = '$ ID'"); // query all the comments in the article id
Return $ query-> result ();
}

This is the code for getting the parent message content

The code is as follows:



Message User: Receiver_author;?> Message content: Content?>



Whether the user logs in and gives the message permission

The code is as follows:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.