I know how to add value within the SQL Query So current value of Bank = Bank + Value
UPDATE users SET Bank=Bank + '$deposit' WHERE Username='".($_SESSION['username'])."'"
As Example if $deposit = '500' so string/text = 500 and Example Bank value is 1000 it is 1500 right. Now i try to substract with current value.
UPDATE users SET Bank=Bank + '-500' WHERE Username='".($_SESSION['username'])."'"
Should be working. What not works is:
UPDATE users SET Bank=Bank + '-' + '$deposit' WHERE Username='".($_SESSION['username'])."'"
or
UPDATE users SET Bank=Bank + '-$deposit' WHERE Username='".($_SESSION['username'])."'"
What should i do?
Alright i've sold it myself, thanks for everyone that tried to help, ya'll brought me on the idea of the answer :
UPDATE users SET Bank=Bank +- '$deposit' WHERE Username='".($_SESSION['username'])."'
instead of only using
-
ive used
+-
Thanks.
您为什么不只使用-
进行减法:
"UPDATE users SET Bank = Bank - $deposit WHERE Username = '{$_SESSION['username']}'"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.