PHP Simple message Board and restore function specifically implemented

Source: Internet
Author: User
Tags foreach comments php foreach

Message board is in the first contact with PHP used to learn a simple application example, today I give a beginner PHP friend to provide a complete PHP message board all the production process, I hope you will be helpful

on the Internet to find this tutorial but basically no one said anything and then one day saw a PHP program designed a database design like this a lot of understanding! The following is the structure diagram of the database   Below we'll go on to the introduction      id                       & This is the parent ID that can be queried by this ID to see if there is a child ID under this ID and can also record this is the id  of that message      son_id         &NBS P           This is the child ID and then through this ID can find the corresponding parent ID    news_id           &NBS P       Record article id     sender_author             message person   &NBS P;receiver_author           Send a message to the person    content                   Message content    status                     in someone reply When you post this value from 0 to 1 when the message is not displayed if not clicked the message still exists    time                 &NBSP ;     Record the time of the message     Message board reply to the idea   when the sender (also the message) to the article under the message or reply to the need for the receiver (also the author of the article or the person to be replied) to receive. Single DATABASE statement query to this key Sender_author and receiver_author will know who the receiver is and who the sender is. And then in accordance with this judgment to show the reply content     Hint you have a new message idea   when the sender sends a message, the value of this status defaults to 0, which is the prompt to receive the send you have a new message. When clicked in, call the database modification statement to modify the specified value to 1 so that it does not show the                     The database language when viewing comments The sentence     code is as follows: Function message ($id) {      $query = $this->db->query ("SELECT * from Message WH ERE news_id = ' $id ');/or Post ID query all comments      return $query->result ();     &NBSP     This is the code to get the parent's message the     code is as follows: <?php foreach ($query as $sel) {?> <p> message User : <?php echo $sel->receiver_author;? > Message content: <?php echo $sel->content?></p> <?php}?>     User login and give message permission     code as follows: &L T;form id= "Form1" Name= "Form1" method= "Post" action= "<?php Echo Site_url ()." /publish/user_message "?>" > <textarea rows= "5" cols= "" Name= "Huifu" <?php if ($uere _name = = "0") {Echo Disabled ";}? > > <?php  if ($uere _name = = "0") {echo "I'm sorry you haven't logged in, you can't leave a message. ?> </textarea> <input class= "Wole name=" author "value=" <?php echo $author;? > "/><!--recipient post author--> <input class=" Wole "name=" news_id "value=" <?php echo $news _idx;? > "/><!--article id--> <input type=" Submit "name=" Submit "/> </form> <script language=" javascript "> Function Updateinfo () {  If <?php echo $uere _name;? > = 1) {    Document.form1.Submit.value = "message";     document.form1.Submit.disabled = false;   }   else{    Document.form1.Submit.value = "Not yet logged in";  document.form1.submit.disabled = "disabled"; &NB Sp } updateinfo (); </script>     This is the display of the specified parent ID to display all of his child IDs and message content   code as follows: <p> here is <?php echo $is;? > Floor User: <?php echo $sel->receiver_author;? > <br/> Message content: <?php echo $sel->content?>      <a onclick= "Showdiv (' contentid<? php echo $is;? > ', ' showtext<?php echo $is;? > ') "href=" JavaScript:void (0) "> Reply </a> <div id=" contentid<?php echo $is;? > "class=" None "> <?php     $query = $this->db->query (" SELECT * from message where son_id = ' $sel-&G T;id ' ORDER by id '); Gets the child reply of the specified parent id   $revis = $query->result ();     foreach ($revis as $row) {?>  <p><?php if ($row->sender_author = = $row->receiver_ Author) {echo $row->sender_author;}    else{Echo $row->sender_author. " replied: ". $row->receiver_author; >   content is: <?php echo $row->content?></p> <?php}?> <form action= "<?php echo Site_url ()." /publish/son_message "?>" method= "POST" > <input name= "son_idx" class= wole "value=" <?php echo $sel->id? > "/> <input name=" Receiver_author "class=" Wole "value=" <?php echo $sel->receiver_author;? > "/> <input class=" Wole "name=" news_id "value=" <?php echo $news _idx;? > "/><!--article id--> <textarea rows=" 5 "cols=" "Name=" Huifux "></textarea> <br><input type= "Submit" Name= "sub" value= "Reply" ></form></div></p> <script language= "JavaScript" type= "Text/javascript" > <!--function Showdiv (TARGETID,OBJN) {        var Target=document.getelementbyid (Targetid);       var Clicktext=document.getelementbyid (OBJN)               if (Targ et.style.display== "Block" {                target.style.display= "none";   & nbsp             clicktext.innertext= "reply";                } else {                T arget.style.display= "Block";                 clicktext.innertext= ' close up ';             { }--> </script>     This is the effect after the implementation of the picture Message board has implemented the message content reply then this is the realization of the reply you will show when you have a new message article source: http://alzhai.com/post-13.html
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.