You will simply need to add package
column on the right side of the operator =
to add the $amount
to itself.
$sql = "UPDATE `table_projects`
SET `package1`= `package1` + " . (int)$amount . "
WHERE `id` = '$userid'";
Notes:
- I have added explicit typecasting to
(int)
on $amount
. If it is going to be decimal/float value, you can use (float)
instead.
- Your code is open to SQL injection related attacks. Even
real_escape_string
cannot secure it completely. Please learn to use Prepared Statements
- If you are not going to use Prepared Statements, and if the
id
($user_id) is integer value.
I would do typecasting on it as well
$sql = "UPDATE `table_projects`
SET `package1`= `package1` + " . (int)$amount . "
WHERE `id` = '" . (int)$userid . "'";