Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2011
    Location
    Australia
    Posts
    13
    Thanks
    3
    Thanked 1 Time in 1 Post

    Simple PHP script adding up numbers

    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

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Code:
    UPDATE your_table
    SET your_column = your_column + 20
    WHERE user_name = 'user1'

  • #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,233
    Thanks
    51
    Thanked 100 Times in 99 Posts
    For an example of what fumigator said. "Also uour script may be different than mine"

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

  • #4
    New Coder
    Join Date
    Jun 2011
    Location
    Australia
    Posts
    13
    Thanks
    3
    Thanked 1 Time in 1 Post
    Thanks guys. Does what I was hoping to do. Much appreciated for the help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •