Imperialdata Posted March 31, 2006 Share Posted March 31, 2006 I have a database which I would like to do the following:In table_userinfo I have columns user_id and user_credits.I wish to add 50 to the number stored in user_credits for a single user (say user_id=5) via a php scriptHow is this best achieved? I have succeeded in retrieving the data from the field using return mysql_fetch_array($res,MYSQL_ASSOC);but I am struggling to add 50 to it and drop it back into the table.Thanks in advance----------------------------------------------------------[a href=\"http://www.TheBikeForum.com\" target=\"_blank\"]Like Motorcycles?[/a]---------------------------------------------------------- Link to comment https://forums.phpfreaks.com/topic/6293-solved-add-to-a-number/ Share on other sites More sharing options...
Barand Posted March 31, 2006 Share Posted March 31, 2006 Simply[code]$creds = 50;$user = 5;$sql = "UPDATE user_info SET user_credits = user_credits+'$creds' WHERE user_id = '$user' ";[/code] Link to comment https://forums.phpfreaks.com/topic/6293-solved-add-to-a-number/#findComment-22739 Share on other sites More sharing options...
Imperialdata Posted April 1, 2006 Author Share Posted April 1, 2006 Thanks, that helps a lot! Link to comment https://forums.phpfreaks.com/topic/6293-solved-add-to-a-number/#findComment-22849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.