onemind Posted November 19, 2005 Share Posted November 19, 2005 Hi, 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. eg 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 Link to comment https://forums.phpfreaks.com/topic/2897-how-to-add-a-number-to-an-int-field/ Share on other sites More sharing options...
ryanlwh Posted November 20, 2005 Share Posted November 20, 2005 $sql = mysql_query("UPDATE profiles SET positive=positive+$positive, negative=negative+$negative,neutral=neutral+$neutral WHERE id=$to") Link to comment https://forums.phpfreaks.com/topic/2897-how-to-add-a-number-to-an-int-field/#findComment-9747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.