我正在尝试创建一个表格,允许我通过单击删除按钮来删除一行。我确实在以下链接上找到了一篇文章,它确实提供了一些帮助,但我仍然无法让它工作:显示 mysql 表中的所有行,然后提供删除特定行的选项。我已经编写了大部分代码,但我delete.php 页面上的第 10 行有问题。想法?
主文件
$result = mysqli_query($con,"SELECT * FROM cs_general_info");
echo "<table><tr><td>Delete</td><td>First Name</td><td>Last Name</td><td>Address</td>td>Phone</td><td>E-Mail Address</td></tr>";
while($row = mysqli_fetch_array($result)) {
?>
<tr>
<td>
<form action="delete.php" method="POST">
<input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>">
<input type="Submit" value="Delete"></form>
</td>
<?php
echo "<td>" . $row['id'] ."</td>";
echo "<td>" . $row['first_name'] . "</td>";
echo "<td>" . $row['last_name'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td>" . $row['email'] . "</td></tr>";
}
echo "</table>";
删除.php
"DELETE FROM cs_general_info WHERE id=".mysql_real_escape_string($delete_id);