0
我想刪除幾行連同foreach
,但我從這個輸出bool(false) not array
從下面的代碼。如何解決它?刪除幾行數組
<input type="checkbox" name="checked[]" value="1">
function delete_test()
{
$delete = $this->input->post('checked');
if (is_array($delete) && count($delete) > 0) {
foreach ($delete as $val) {
$this->db->query("DELETE FROM hotel_units WHERE relation LIKE '$val'");
}
var_dump($delete);
echo "<br>is array";
} else {
var_dump($delete);
echo "<br>not array";
} // This output is: bool(false) not array
}
請閱讀:[停止SQL注入PHP的最佳方法](http://stackoverflow.com/questions/60174/best-way-to-stop-sql-injection-in-php)(只要你不保證你的查詢是有效的,你不能指望它按預期運行) – hakre
爲什麼你不使用print而不是var_dump在其他情況下? –
你有沒有嘗試過:$ delete = $ this-> input-> post ['checked']; – SW4