ueon Posted June 27, 2011 Share Posted June 27, 2011 if ($addexperience) { $getexpx = mysql_query("SELECT exp FROM profile WHERE profileid='$id'"); $getexp = mysql_fetch_row($getexpx); $exp = $getexp['exp']; $expreal = $exp + 50; $insertexp = mysql_query("UPDATE work SET exp='$expreal' WHERE WorkID='$workid'"); echo $expreal; } the 'exp' starts are 0, and only adds up to 50, but I'd like it add 50 every time this code is executed Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/ Share on other sites More sharing options...
Pikachu2000 Posted June 27, 2011 Share Posted June 27, 2011 You select the same value from the exp table every time and add 50 to it, thus the result is the same every time. Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/#findComment-1235520 Share on other sites More sharing options...
ueon Posted June 27, 2011 Author Share Posted June 27, 2011 so what do I have change to make it work? :\ Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/#findComment-1235522 Share on other sites More sharing options...
Pikachu2000 Posted June 27, 2011 Share Posted June 27, 2011 Well, it depends on what your end goal is. Is all that's necessary to add 50 to the value of `exp` in the `work` table each time the query runs or is there a specific reason you have it tied to the `exp` table as well? Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/#findComment-1235534 Share on other sites More sharing options...
ueon Posted June 27, 2011 Author Share Posted June 27, 2011 i'm good as long it adds the value to 100, 150, 200, etc. Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/#findComment-1235538 Share on other sites More sharing options...
Pikachu2000 Posted June 27, 2011 Share Posted June 27, 2011 This query string will do that, as long as $workid contains the proper value. UPDATE work SET exp = (exp + 50) WHERE WorkID='$workid' Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/#findComment-1235539 Share on other sites More sharing options...
ueon Posted June 27, 2011 Author Share Posted June 27, 2011 works great Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/#findComment-1235554 Share on other sites More sharing options...
mikosiko Posted June 27, 2011 Share Posted June 27, 2011 [OT] .... your nickname make me laugh... hopefully it doesn't represent you Quote Link to comment https://forums.phpfreaks.com/topic/240536-cant-add-database-values/#findComment-1235555 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.