我很難看到這裏出了什麼問題。我正在嘗試從我的數據庫中刪除基於哪些複選框已被選中。 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