<分区>
我有一个更新 MySQL 数据库的 PHP 表单。我想将学分添加到行中的当前学分。基础数学
当前积分 50 再加上 50 积分 = 100
这是我当前的字符串(已编辑)
$sql = sprintf("UPDATE h_clients ". "SET credits = $credits + '%s'" . "WHERE id = $id",
Currently this works but it doesn't add the new credits with the current credits in DB
Here is the full code:
$sql = sprintf("UPDATE h_clients ". "SET credits = $credits + '%s'" . "WHERE id = $id",
mysql_real_escape_string($credit),
mysql_real_escape_string($id));
if (mysql_query($sql, $con)) {
$insertSuccessful = true;
} else {
echo $sql;
echo "\n" . mysql_error($con);
echo "mysql err no : " . mysql_errno($con);
}
}
}
return $insertSuccessful;