thewhat Posted January 8, 2008 Share Posted January 8, 2008 I've got a form and a script that updates a number of columns in my DB upon activation. I'm now trying to add a section that adds into a certain column. For instance, say the column has the number 15. The piece of code should add 5 more, updating it to 20. How would I do this? Quote Link to comment https://forums.phpfreaks.com/topic/84982-solved-adding-into-a-db/ Share on other sites More sharing options...
GingerRobot Posted January 8, 2008 Share Posted January 8, 2008 Well, the query would be something like: UPDATE tbl SET col = col +5 Im not entirely sure if that's what you were asking though. Quote Link to comment https://forums.phpfreaks.com/topic/84982-solved-adding-into-a-db/#findComment-433381 Share on other sites More sharing options...
thewhat Posted January 8, 2008 Author Share Posted January 8, 2008 $addition = ($userdata['user_AvailableTurns'] + 5); $result = dbquery("UPDATE ".$db_prefix."users SET user_LastManagement= '$now', user_AvailableTurns = '$addition' WHERE user_id='".$userdata['user_id']."'") or die(mysql_error()); This worked. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/84982-solved-adding-into-a-db/#findComment-433388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.