Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.