So I have this three lines, and the problem is that only the last one is updating. What am I doing wrong? What can I do to them to update all three at the same time?
$query = "UPDATE arak SET ara = '$konyha' WHERE ID = 1";
$query = "UPDATE arak SET ara = '$kugli' WHERE ID = 2";
$query = "UPDATE arak SET ara = '$ronk' WHERE ID = 3";
You should execute each single query otherwise you execute only the last query assigned at $query
$query = "UPDATE arak SET ara = '$konyha' WHERE ID = 1";
your_execute_command() ... ;
$query = "UPDATE arak SET ara = '$kugli' WHERE ID = 2";
your_execute_command() ... ;
$query = "UPDATE arak SET ara = '$ronk' WHERE ID = 3";
your_execute_command() ... ;
or could yuo ca use a single query with a case clause
UPDATE arak
SET ara = case when ID = 1 then '$konyha'
when ID = 2 then '$kugli'
when ID = 3 then '$ronk'
else ara
end
只需将这些查询组合在一个由终止符分隔的字符串中,然后使用:
mysqli_multi_query($connection,$query);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.