我的代码有什么问题?
我的PHP正常运行,但删除按钮无效!
if(isset($_POST['delete'])) {
$ID = $_POST['value'];
$delete = "DELETE FROM tbl_document WHERE ID = $ID";
$result = mysqli_query($con,$delete);
}
$query = "SELECT * FROM tbl_document LIMIT $start, $end";
$result = mysqli_query($con,$query);
echo "<table border='1' width='300' height='160' align = center id='result'>";
echo '<tr>
<th width="80">ID</th>
<th width="200">Title</th>
<th width="260">Presented To</th>
<th width="260">Presented By</th>
<th width="160">Date Submitted</th>
<th>Location</th>
<th width="17%">Option</th>
</tr>';
while($row = mysqli_fetch_array($result)){
echo "<tr align = center >";
<td width='20' height='60'>" .$row['ID']. "</td>";
<td width='120' height='60'>" .$row['Title']. "</td>";
<td>" .$row['Presented_To']. "</td>";
<td>" .$row['Presented_By']. "</td>";
<td>" .$row['Date_Submitted']. "</td>";
<td>" .$row['Location']. "</td>";
"<td width='17%'>";
?>
<?php if($_SESSION['user'] == "1")
?>
<button class="w3-btn w3-red w3-border-large w3-circle" value="<?php echo $row['ID'];?>" name="delete" style="width:40%"><i class="fa fa-trash-o"></i>Delete</button>
<?php } ?>
<?php
echo "</td>";
echo "</tr>";
}
echo"</table>";
答案 0 :(得分:0)
button
不足以发送数据,您需要将其包含在form
内。
以下是它的样子:
<form method="post">
<button name="delete" value="<?php echo $row['ID'];?>" class="w3-btn w3-red w3-border-large w3-circle" style="width:40%"><i class="fa fa-trash-o"></i>Delete</button>
</form>