我很难看到这里出了什么问题。我正在尝试根据已选中的复选框从我的数据库中删除。if(!empty($_POST['removeCheckbox'])) 说 removeCheckbox 是空的,即使我回显 $currentRow[] 它显示值。提前致谢。
while($row = mysqli_fetch_array($paperToReview)){
if ($row > 0) {
$currentRow = array($row['uid'], $row['toReview']);
echo $currentRow[0];
echo $currentRow[1];
echo '<td width = 200><input type="checkbox" name="removeCheckbox[]" value="'.$currentRow.'"> Remove</td>';
}
}
//Remove button
echo'<td width = 200><td width = 200><td width = 200><td width = 200><td width = 200><input type=submit name=submit value="Remove Checked Rows"></td>';
然后在这里我查看删除按钮是否已被选中并查看所有选中的框。
if (isset($_POST['submit']) && $_POST['submit'] =="Remove Checked Rows"){
if(!empty($_POST['removeCheckbox'])) {
//deletes row from database
foreach($_POST['removeCheckbox'] as $check) {
DBSubmit("DELETE FROM paper_review WHERE paper_reviewer_id = '" . $check[0] ."' AND paperid = '" . $check[0] ."'");
}
}