Jump to content

[SOLVED] Simple MySQL "UPDATE" question.


MasterACE14

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/72899-solved-simple-mysql-update-question/
Share on other sites

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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.