Add value to SQL table instead of replacing

3

Using the following code:

UPDATE 'login' SET diasvip = '".+$_POST["qntvip"]."' WHERE userid = '".$_POST["userid"]."'

When I run, it replaces the diasvip with the posted value instead of adding the value to those already in the table. How do I do the sum operation?

    
asked by anonymous 07.03.2015 / 15:40

1 answer

6

If you want to add to what already exists you should do this, like this:

"UPDATE 'login' SET diasvip = diasvip +".$_POST["qntvip"]." WHERE userid = '".$_POST["userid"]."'"

Note that you are assembling a string so the plus sign should already be inside the text, what you put outside the text is just what it varies.

And you should not put apostrophe in all data, only when it is a character, in case of quantity that is a number, should not have.

    
07.03.2015 / 15:45