num_rows > 0) { while($row = $result->fetch_assoc()) { $state = $row["state"]; } } else { echo "未找到匹配的记录"; } if ($state == 0) { $new_state = 1; } else { $new_state = 0; } mysqli_query($con, "set names utf8"); $sql = "UPDATE `list` SET state = '$new_state' WHERE id = '$id'"; if ($con->query($sql) === TRUE) { echo ""; } else { echo ""; // echo "Error updating record: " . $con->error; } }