Re: Add or Subtract

From: Date: Thu, 19 Jan 2006 12:36:56 +0000
Subject: Re: Add or Subtract
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-41074@lists.php.net to get a copy of this message
On Thu, 19 Jan 2006 22:55, Ed wrote: > I've been considering doing a little project for my community site > which allow people to sell and buy players ... They would have a limit > of 2,000,000 upon sign up .. However i'm not sure how i'd update this > figure .... > > Say player sells for example Alan Shearer for £300,000 he'd then have > 2,300,000 how would i make it add to whats in the db already? same goes > for if he was sold and it went down to 1,700,000. > > Ed You haven't read the mysql docs much, I guess. Assuming you are storing your limit as an integer: UPDATE table SET value = value + $newamount WHERE [something to identify the record to be updated] where $newamount is the positive or negative value of the increase passed in from wherever. Cheers -- David Robley Press any key to continue or any other key to quit...

« previous php.db (#41074) next »