所以我想用 php 更新 mysql 数据库中的多行,这段代码只更新最后一行。我需要添加什么才能更新所有行?
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "cases";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$Famas_Doomkitty_mn = 1,54;
$Famas_Doomkitty_ft = 1,46;
$Famas_Doomkitty_mnst = 2,57;
$Famas_Doomkitty_ftst = 2,42;
$sql = "UPDATE esports2013skins SET FAMASDoomkitty='$Famas_Doomkitty_mn' WHERE id=2";
$sql = "UPDATE esports2013skins SET FAMASDoomkitty='$Famas_Doomkitty_ft' WHERE id=3";
$sql = "UPDATE esports2013skins SET FAMASDoomkitty='$Famas_Doomkitty_mnst' WHERE id=7";
$sql = "UPDATE esports2013skins SET FAMASDoomkitty='$Famas_Doomkitty_ftst' WHERE id=8";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
互换的青春