I have a table field that shows how many "credits" a user has. I need to update this table according to whether or not they use credits, or buy credits.
I'd like to be able to do it all on the fly with one query, but not sure if that's possible. I know I could do it with two (first select what they have, then use php to add or subtract, then update).
Is it possible to just do it all with one query? I was thinking of a subquery (I have 4.1), but even then not sure how I could throw some php in there to reflect the new amount??
any ideas?
thanks,
Burrito
update table with subtraction or addition
Moderator: General Moderators
d11 got me there with this:
thx mang!
Code: Select all
$query = "e;UPDATE table SET credits = (credits+$value) WHERE whatever"e;;