现在这是我的表格/表格 anvandare.php :
<?php
$query = "select * from user order by date DESC";
$run = $mysqli->query($query);
while($row=mysqli_fetch_array($run)){ //Hämtar informationen från användaren
$userID = $row['userID'];
$email = $row['email'];
$company = $row['company'];
$fname = $row['fname'];
$tel = $row['tel'];
$test_status = $row['test_status'];
$date = $row['date'];
?>
<td><?php echo $userID; ?></td>
<td><?php echo $email; ?></td>
<td><?php echo $company; ?></td>
<td><?php echo $fname; ?></td>
<td><?php echo zero($tel); ?></td>
<td><?php echo $date; ?></td>
<td><?php echo $test_status; ?></td>
<form action="delete.php" method="POST">
<td><input type="checkbox" name="<?php echo $userID;?>" value="checked"></td>
</tr>
<?php } ?>
<tr><td><input type="submit" value="Skicka"></form></td></tr>
</table>
这是我现在的 delete.php ..:
<?php
mysql_connect("localhost","root", "");
mysql_select_db("Webbprojekt");
if(isset($_POST))
{
var_dump($_POST);
}
?>
你有继续如何继续吗? 当我提交时,我得到这个: Three checked in
答案 0 :(得分:0)
您可以使用foreach-loop:
foreach($_POST as $userID => $value){
// use $userID to delete the database-entry here
}
如果您将输入的名称更改为userIds[<? echo $userID; ?>]
,您将在接收页面上获得数组$_POST['userIds']
,如果您想添加更多带有附加信息的输入,这将非常有用。这个数组可以像上面一样使用:
foreach($_POST['userIds'] as $userID => $value){
// use $userID to delete the database-entry here
}