Re: Add or Subtract

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux