Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Increment DB Column Value using HTML Form

Status
Not open for further replies.

WilliamMute007

Programmer
Sep 30, 2007
116
GB
Hi,

Me again.. :( can anyone please advice how I can increment the value in my DB table. Say for example, Add 2 to the number of user so if number of user was 100 before, it will now be 102. (using a HTML form)

Code:
("UPDATE tablename SET column = column ++ 2 WHERE column ID = $var"); ???

And where I need to update multiple columns how can I go about that? Say increment column 1 +1 Column 2 + 1 Column 3 + 1 etc...


Would it be something like that?
 
this is more a mysql question. you might be better off asking in that forum.

but this should work

Code:
update tablename set column=column + 2, column2=column2 + 3 where anothercolumn=$variable
 
Thanks Justin.. I havent tried it yet but will do at some point this evening. Am just thinking ahead of myself. Thanks tho. Will let you know if it works!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top