亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php實現(xiàn)評論回復(fù)刪除功能

 更新時間:2017年05月23日 09:01:28   作者:ChrissZhao  
這篇文章主要為大家詳細(xì)介紹了php實現(xiàn)評論回復(fù)刪除功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

簡單的評論回復(fù)刪除功能,具體內(nèi)容如下

一、數(shù)據(jù)庫

建立兩張表,一是pinglun表;二是huifu表

 效果如下:

代碼如下:

1.主頁面 main.php

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標(biāo)題文檔</title>
 
 
 
<h1>朋友圈</h1>
<div>內(nèi)容:</div>
<div>今天很嗨</div>
<div><img src="../picture/timg.jpg" width="300" height="200"></div><br>
<form action="mainchuli.php" method="post">
 
<input type="text" hidden="hidden" value="zhangsan" name="zhangsan"> <!--因為沒有權(quán)限,這里給了一個默認(rèn)值-->
 
<textarea name="content"></textarea><input type="submit" value="評論"><!--評論顯示的地方--><!--單擊評論提交內(nèi)容進(jìn)處理頁面-->
</form>
 
 
<!--?php
  require"DBDA.class.php"; //調(diào)用封裝類注意修改數(shù)據(jù)庫名
  $db = new DBDA();
  $sql ="select * from Pinglun";
  $arr = $db--->query($sql,1);
  foreach($arr as $v)
  {
    echo"
       <div style="color:blue">{$v[1]} {$v[3]}</div>
       <div style="color:blue">{$v[2]}</div>
       <form action="delchuli.php?id={$v[0]}" method="post"> //刪除按鈕
        <input type="submit" value="刪除">
       </form>
       <form action="huifuchuli.php?id={$v[0]}" method="post"> //回復(fù)按鈕
        <textarea name="Comment"></textarea><input type="submit" value="回復(fù)">
       </form>
       ";
       
      $dc = new DBDA(); 
      $sql1 ="select * from huifu where jieshouid ={$v[0]}"; //查詢回復(fù)表中的id和傳過去的id是不是一樣的
          $arr1 = $dc->query($sql1,1);
      foreach($arr1 as $k)
      {
        echo "<div>{$k[2]} {$k[3]}</div>
           <div>{$k[4]}</div>
           ";
      }
         
  }
     
?>

 2.評論處理頁面 pinglunchuli.php

<?php
$zhangsan = $_POST["zhangsan"];
$content = $_POST["content"];
$time = date("Y-m-d H:i:s");
 
require "DBDA.class.php";
$db = new DBDA();
$sql = "insert into Pinglun values('','{$zhangsan}','{$content}','{$time}')";
$db->query($sql);
header("location:main.php");

 3.回復(fù)處理頁面 huifuchuli.php

<!--?php
$id = $_GET["id"]; //將點擊回復(fù)的評論id傳過來
$Comment = $_POST["Comment"]; //回復(fù)文本域中的內(nèi)容
$me = "me"; //這里是給定義了一個人
$Times = date("Y-m-d H:i:s");
 
require "DBDA.class.php";
$db = new DBDA();
$sql = "insert into huifu values('','{$id}', '{$me}','{$Times}','{$Comment}')";
$db--->query($sql);
header("location:main.php");

 4.刪除處理頁面 delchuli.php

<?php
$id = $_GET["id"];
require "DBDA.class.php";
$db = new DBDA();
$sql = "delete from Pinglun where id='{$id}'";
if($db->query($sql))
{
 
  header("location:main.php");
}
else
{
  echo "刪除失??!";
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論