Auto increment php variable from database for different users

Discussion in 'PHP' started by shivampaw, Nov 18, 2013.

  1. #1
    I have this code:
    mysql_query("UPDATE users SET admin='1'");
    Code (markup):
    But now instead of it just making admin='1' I want it to make admin equal to its current value+1 this will need to happen for all users.

    eg.
    User 1 that has admin=0 will become admin=1
    User 2 that has admin=1 will become admin=2

    How can I do achieve this?
     
    Solved! View solution.
    shivampaw, Nov 18, 2013 IP
  2. #2
    UPDATE users SET admin=admin+1
     
    PoPSiCLe, Nov 18, 2013 IP
  3. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Clarify :
    mysql_query("UPDATE users SET admin='admin+1'");
    PHP:
     
    shivampaw, Nov 18, 2013 IP
  4. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Thanks it worked, I added ' ' which made it failed but without it, it worked.

    Thanks :D

     
    shivampaw, Nov 18, 2013 IP