【发布时间】:2015-08-14 13:37:22
【问题描述】:
所以我正在制作这个网站,并在我的数据库中获得了一些数据。使用 php 将数据自动读取到表中。每个表格行也会自动获得一个复选框。现在我想选中复选框,然后按删除,它将检查的数据从数据库中删除。有什么想法吗?
这是我的代码:
<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Username</th>
<th>Paswoord</th>
<th>Delete</th>
</tr>
<?php
while($user = mysql_fetch_assoc($records)){
echo "<tr>";
echo "<td>".$user['UserName']."</td>";
echo "<td>".$user['Pass']."</td>";
echo "<td> <input type='checkbox' name='checkbox' value='checked'</td>";
echo "</tr>";
}
?>
</table>
<form method= "POST" action="deleteuser.php">
<input type="submit" name="delete" value="DELETE USERS">
</form>
这是我删除 user.php 中的代码
$checked = $_POST['checkbox'];
if($_POST['checkbox'] == "checked"){
echo "SUCCEEEEEEES";
}
【问题讨论】: