我的页面上有以下表格view_feedback.php
//Retrieve feedback info from database
$query = $db->prepare("SELECT * FROM feedback ORDER BY ID desc");
$query->execute();
//Display feedback info in table
echo "<table id='user' class='table table-bordered'>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Message</th>
</tr>
</thead>";
while ($dbRow = $query->fetch(PDO::FETCH_ASSOC)) {
$id = $dbRow['ID'];
$name = $dbRow['Name'];
$email= $dbRow['Email'];
$message = $dbRow['Message'];
{ echo "<tr>
<td>$id</td>
<td>$name</td>
<td>$email</td>
<td>$message</td>
<td>" . " <input type='submit' action='view_feedback.php' id= '$id' . ' value='Delete' >" . "</td>
</tr>"
;}
}
echo "</table>";
然后我有这个代码来执行删除:
if (isset($_POST['delete'])){
$query = $db->prepare (DELETE * FROM feedback WHERE ID = ?)
$query->execute($id);
}
表显示正常,但是当我点击删除按钮时没有任何反应?
答案 0 :(得分:0)
<input type='submit' action='view_feedback.php' id= '$id' . ' value='Delete' >
它应该有一个名称=&#39;删除&#39;这样$ _POST可以检索它:
<input type='submit' name = 'delete' action='view_feedback.php' id= '$id' . ' value='Delete' >