Updating an amount

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Updating an amount

Post by hame22 »

Hi

I have a database that holds data regarding registered members, this includes an amount of credits within a users account.

What I want to do is quickly updatethe users credits when they purchase some more.

I know i could do that by first finding out the users current credit amount from a query, put that into a variable, then add the new credit amount to the current balance to make a new varibale and then run another query to update the users record.

However I was wondering out of interest if all this could be achieved through one query or perhaps less code?

thanks in advance
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Code: Select all

update users set credits = credits+10000 where user_id = '1';
Post Reply