我正在尝试使用foreach将多个值更新到表字段中。 $ v = implode(“,”,$ v); 返回 3,4,5,。但是,在db表中,它只更新上一个值 5,。如何更新所有值?
foreach($var1[57] as $v) {
$v = implode(",",$v); // THIS RETURNS 3,4,5,
$sql = "UPDATE ".GAME_REQUIREMENTS_DB." SET operating_system_os = '".$v."' WHERE post_id = '".$id."' ";
}
var_dump($sql);
$update_query = $dbh->prepare($sql);
$update_query->execute();
答案 0 :(得分:0)
我试过这个并且有效
$sql = "UPDATE ".GAME_REQUIREMENTS_DB." SET operating_system_os = '";
foreach($var1[57] as $v) {
$sql .= "".$v."| ";
}
$sql .= "' WHERE post_id = '".$id."'";