在WHERE字段的UPDATE SQL查询中,该变量被错误地比较。 如果使用此选项替换“ WHERE”字段,则代码有效:
WHERE `Id` = "1"
Main
表格:
Group_IDGroup
(int)1 Human_IDHuman
(int)1 Month_IDMonth
(int)1 DayID
(int)1 Pos
(int)0 Id
(int)1 ================================================ =======================
例如,我尝试更改所有字符的数量和位置
$result[Id]
$result["Id"]
"$result["Id"]"
\"$result[\"Id\"]\"
".$result["Id"]."
这是一整段无效的代码。
$sqlchk = mysqli_query($link, 'SELECT `Group_IDGroup`, `Human_IDHuman`, `Month_IDMonth`, `DayID`, `Pos`, `Id` FROM `Main`');
$result = mysqli_fetch_array($sqlchk)
$query = 'UPDATE `main` SET `Pos` = "!Pos" WHERE (`Id` = "$result[Id]")';
$sqlposchk = mysqli_query($link, $query);
答案 0 :(得分:-2)
正确答案:
$ query =“ UPDATE main
SET Pos
=!Pos WHERE(Id
='{$ result ['Id']}')”;