Jump to content


Photo

How to add a number to an int field?


  • Please log in to reply
1 reply to this topic

#1 onemind

onemind
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 19 November 2005 - 11:30 AM

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 :)

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 20 November 2005 - 09:18 PM

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

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users