Let's first look at the function
Above the black is the comment below the red font is reply
and see how it's going to come true.
1. Post a comment
<form action= "pinglunchili.php" method= "POST" ><textarea name= "content" ></textarea><div> <input type= "Submit" value= "comments"/></div></form>
This is the text field of the comment
Post-comment content to be stored in the database to process
Because this is just to implement a simple comment and reply so there is no login permission so the name inside is added.
<?php$yonghu= "Caocao"; $content =$_post["content"; $time = date ("y-m-d h:i:s"); require "DBDA.class.php"; $db = New Dbda (); $sql = "INSERT into Pinglun values (', ' {$yonghu} ', ' {$content} ', ' {$time} ')", if ($db->query ($sql, 0)) { Header ("location:pinglun.php");} Else{echo "you entered the error! ";}
2. Reply function Here is a comment followed by a reply
<?phprequire "DBDA.class.php"; $db =new Dbda (); $sql = "SELECT * from Pinglun"; $arr = $db->query ($sql); foreach ($arr As $v) {echo "<div>{$v [0]}</div> <div>{$v [1]}</div> <div>{$v [2]}</div > <div>{$v [3]}</div> <form action= ' huifuchuli.php?id={$v [0]} ' method= ' post ' > <input type= ' text ' name= ' Comment '/> <input type= ' submit ' value= ' reply '/></form> '; $dc = new Dbda (); $sql 1= "select * from Huifu where jieshouid={$v [0]}"; $arr 1= $dc->query ($sql 1); foreach ($arr 1 as $f) {echo "<div Style= ' color:red ' >{$f [0]}</div> <div style= ' color:red ' >{$f [2]}</div> <div style= ' color:red ' >{$f [3]}</div> <div style= ' color:red ' >{$f [4]}</div> ";}}? >
The content of the comment and the content of the reply are traversed to show the effect in the diagram.
This allows you to implement a comment followed by a reply
3. Then delete the message
is to add a Delete button to the front of the reply.
<form action= ' shanchuchuli.php?id={$v [0]} ' method= ' post ' > <input type= ' submit ' value= ' delete '/></ form> <form action= ' huifuchuli.php?id={$v [0]} ' method= ' post ' > <input type= ' text ' name= ' Comment '/> <input type= ' submit ' value= ' reply '/></form> ';
Working with pages
That's it. The delete button in the diagram
Let's try the effect:
This will delete the information.
Plus the login and permissions feature will be updated later.
PHP for simple comment and reply function and delete information