View Full Version : Simple PHP script adding up numbers

06-23-2011, 01:21 PM
Hey guys.

I'm a total noob at PHP & MySQL. I want to write a simple script to add numbers into a database. I also want to be able to add up (as in methematical addition) further numbers in.

Eg. user1 has 50 points. he earns 20 pts. So how do I add it so he has 70 points?

I am not an expert and I'm just randomly thinking up scripts to write so I can learn things. Any help is appreciated :)

06-23-2011, 04:24 PM
UPDATE your_table
SET your_column = your_column + 20
WHERE user_name = 'user1'

06-24-2011, 03:02 PM
For an example of what fumigator said. "Also uour script may be different than mine"

mysql_query("UPDATE users SET points=points+20 WHERE id='" . row["id"] . "' LIMIT 1");

07-01-2011, 06:57 AM
Thanks guys. Does what I was hoping to do. Much appreciated for the help :thumbsup: