update table

Discussion in 'PHP' started by roice, Feb 27, 2011.

  1. #1
    Hello,
    I sit possoble to update int field without druping the data first? for example:
    					$query = "UPDATE users SET new_pm=new_pm+1  WHERE ....";
    $res = mysql_query($query);
    PHP:

     
    roice, Feb 27, 2011 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    druping the data?

    your code snippet looks like you are on the right track, I think, but it all depends on "druping".
     
    sarahk, Feb 27, 2011 IP
  3. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm not sure I can do " new_pm=new_pm+1" in SQL query....
    can I?
     
    Last edited: Feb 27, 2011
    roice, Feb 27, 2011 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    yes you can.

    It always pays to open up phpMyAdmin, SQLYog or whatever you use and test them out to ensure you get the result you expect.
     
    sarahk, Feb 27, 2011 IP