答案 0 :(得分:1)
使用[]
表示法创建一个具有相同名称的复选框列表,但大概是不同的值,记录ID:
<input type="checkbox" name="record_id[]" value="42" />
<input type="checkbox" name="record_id[]" value="43" />
<input type="checkbox" name="record_id[]" value="44" />
<input type="checkbox" name="record_id[]" value="45" />
选择其中一些后,它们将作为$_POST['record_id']
数组传递给服务器。
执行foreach
:
foreach ($_POST['record_id'] as $id) {
// delete record with $id here
}
或implode'em,例如:
$sql = "DELETE FROM `mytable` WHERE id IN (" . implode(', ', $_POST['record_id']) . ")";