:
// first setup your MySQLi connection
$db = new mysqli('localhost', 'user', 'pass', 'dbname');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit;
}
// disable autocommit for transactions
$db->autocommit(false);
// **EDIT** forgot to escape input data. fixed now. note the mysqli_real_escape_string() and int type casting
foreach ($_POST['camera_type'] as $type) {
// assuming 'id' is set in the POST array
$query = sprintf(
'UPDATE table SET column = "%s" WHERE id = %d',
$db->real_escape_string($type),
(int) $_POST['id']
);
$db->query($query);
}
// commit transactions (or commit the updates that were run) and then close
$db->commit();
$db->close();
あなたはUPDATEクエリを実行すると、あなたはどのようなエラーを取得していますか?他の投稿にすべてのコードがあるようです。 – Homer6