MasterACE14 Posted October 12, 2007 Share Posted October 12, 2007 Evening Everyone, I have a simple question, with the following query: <?php $sql = "UPDATE `cf_users` SET strikeaction = '$strike_action', defenceaction = '$defence_action', covertaction = '$covert_action' WHERE `id` = '$player_accountid';"; to update every account in my database would I simply remove the "WHERE" ? Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/72899-solved-simple-mysql-update-question/ Share on other sites More sharing options...
Barand Posted October 12, 2007 Share Posted October 12, 2007 Yes. An UPDATE without a WHERE is applied to every row. Quote Link to comment https://forums.phpfreaks.com/topic/72899-solved-simple-mysql-update-question/#findComment-367677 Share on other sites More sharing options...
MasterACE14 Posted October 12, 2007 Author Share Posted October 12, 2007 ok, Thankyou barand, I have 1 more question. I have some code to workout what will be UPDATE'ed in every account, and I am wondering, how would I make it workout the correct values to input for each user. Here's practically what I have(theirs more to it, but this is the actual part): <?php // Players Actions $strike_action = (($equippedweapondamage + $player_strength) + $equippedvehiclepower) * 100; $defence_action = (($equippedarmordefence + $player_agility) + $equippedvehiclepower) * 100; $covert_action = ($equippedvehiclepower + $player_intelligence) * 100; // Workout the Players Income // $players_income = ((($strike_action * $defence_action) * $covert_action) / 100000000); Every user will have different, strike, defence and covert actions, which would change what their income is. Now how would I make these variables change to suit each user for the MySQL "UPDATE" ? or would UPDATE'ing the database with my query I have above do this automatically? Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/72899-solved-simple-mysql-update-question/#findComment-367682 Share on other sites More sharing options...
Barand Posted October 12, 2007 Share Posted October 12, 2007 $strike_action = (($equippedweapondamage + $player_strength) + $equippedvehiclepower) * 100; if strike_action, equippedweapondamage, player_strength, equippedvehiclepower are columns in the table you can use that expression in the update UPDATE cf_users SET strike_action = ((equippedweapondamage + player_strength) + equippedvehiclepower) * 100 and have SQL calculate the value for each user Quote Link to comment https://forums.phpfreaks.com/topic/72899-solved-simple-mysql-update-question/#findComment-367684 Share on other sites More sharing options...
MasterACE14 Posted October 12, 2007 Author Share Posted October 12, 2007 ok, thank you, that should work Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/72899-solved-simple-mysql-update-question/#findComment-367685 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.