我很难看到这里出了什么问题。我正在尝试从我的数据库中删除基于哪些复选框已被选中。 if(!empty($ _ POST ['removeCheckbox']))表示removeCheckbox是空的,即使当我回显$ currentRow []时它显示值。提前致谢。从复选框中检索数组值php
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] ."'");
}
}
,我以前有下一个报头(重定向())在那里看到它正在工作 – 2013-05-13 21:30:25
实际上if(!empty($ _ POST ['removeCheckbox']))检查不起作用。我会尽力解决这个问题 – 2013-05-13 21:34:45