gpt4 book ai didi

php - 删除php表中每一行的按钮

转载 作者:行者123 更新时间:2023-11-30 22:43:19 26 4
gpt4 key购买 nike

我的页面 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);
}

表格显示正常,但是当我点击删除按钮时没有任何反应?

最佳答案

<input type='submit' action='view_feedback.php' id= '$id' . ' value='Delete' >

它应该有一个 name = 'delete' 以便 $_POST 可以检索它:

<input type='submit' name = 'delete' action='view_feedback.php' id= '$id' . ' value='Delete' >

关于php - 删除php表中每一行的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30444637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com