Donald8274 Posted July 22, 2011 Share Posted July 22, 2011 Hello, I just started learning SQL / PHP. I need to know how to set a variable in a column through PHP. I have manually set "credits" to 100 and I'd like to take 10 off that number every time and set the number in the database. The database table is "test". Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/242652-set-table-variable-in-mysql-with-php/ Share on other sites More sharing options...
Maq Posted July 22, 2011 Share Posted July 22, 2011 You can do arithmetic directly in SQL: UPDATE test SET credits = credits - 10 WHERE id = 1 Quote Link to comment https://forums.phpfreaks.com/topic/242652-set-table-variable-in-mysql-with-php/#findComment-1246298 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.