我试图将表中的值增加一个,但我并不是真的知道mysql而且我不知道什么是错的。它似乎没有问题但是当我检查数据库时,数字没有改变。提前致谢! :)
$con = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
echo "it works!";
}
switch ($_POST['found']) {
case "facebook":
mysqli_query($con,"UPDATE `found` SET `number` = 'number + 1' WHERE `id` = 'Facebook'");
break;
答案 0 :(得分:1)
试试这个:
case "facebook":
mysqli_query($con,"UPDATE `found` SET number = number + 1 WHERE `id` = 'Facebook'") or die(mysqli_error($con));
希望这有帮助。