3 回答

TA貢獻1859條經驗 獲得超6個贊
由于您無法將值(數字)與控制流邏輯(逗號)與準備好的語句混合使用,因此每個值需要一個占位符。
$idlist = array('260','201','221','216','217','169','210','212','213');
$questionmarks = str_repeat("?,", count($idlist)-1) . "?";
$stmt = $dbh->prepare("DELETE FROM `foo` WHERE `id` IN ($questionmarks)");
然后循環綁定參數。

TA貢獻1850條經驗 獲得超11個贊
解決方案:<input type="checkbox" name="foos[]" value="bar">
提交后,我得到一個名為的變量$_POST['foos']
,它是所有復選框的值的數組。然后://與數組條目一樣多的問號;最后一個不需要逗號, $questionmarks = str_repeat("?,", count($_POST['foos'])-1) . "?"; $query = "DELETE from
employee_customeraccount`在哪里id
($ questionmarks)“; $ st = $ db-> prepare($ query); //每個問號都用數組$ st-> execute( $ _POST ['foos']);`有效!
- 3 回答
- 0 關注
- 778 瀏覽
添加回答
舉報