Jump to content


This topic is now archived and is closed to further replies.


How to add a number to an int field?

Recommended Posts



I have what i thought was a simple problem but i cant figure it out.

All i want to to, is add a value to an in field.




If i had an int field called number and in it was the value 5, what i want to do is add three to it so number becomes 8.


I use the UPDATE method in mysql like so


$sql = mysql_query("UPDATE profiles SET positive=$positive, negative=$negative,neutral=$neutral WHERE id=$to")


this is supposed to add the int value $positive ect to whats already in the positive column but the way i'm doing it now it just replaces whats in the column. So instead of adding 3 like my previous example to make 8, it replaces the 5 with 3.


Hope that makes sense. :)


Thanks for any help :)

Share this post

Link to post
Share on other sites
 $sql = mysql_query("UPDATE profiles SET positive=positive+$positive, negative=negative+$negative,neutral=neutral+$neutral WHERE id=$to")

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.