Jump to content

[SOLVED] Very Strange - values in MySQL columns aren't what they are suppose to be?


MasterACE14

Recommended Posts

Evening PHP Freaks,

 

I have a file which is suppose to UPDATE every user's 'money' column, but the SELECT's I am using for every person isn't getting the right value.

 

here is the basics of the script:

<?php
// Workout the Players Income //
$players_income = ($all_supplydrop_amount * $all_supplysize_amount);


/****** Give Players their Income ******/

// SQL query to update the players account into the database
$sqlzx = "UPDATE `cf_users` SET `money`=`money`+{$players_income}";

 

now, I'm not really interested in using my variables that SELECT to complete this, but are more interested in letting MySQL do the maths instead.

 

The only problem is I need 2 columns from my `cf_users2` table, and I am updating `money` column in `cf_users`.

 

So, if they were in the same table I would do the query like this:

<?php
$sqlzx = "UPDATE `cf_users` SET `money`=`money`+`amount_supplydrop`*`amount_supplysize`";

how can I do the same query above, but with `amount_supplydrop` and `amount_supplysize` which are actually in the `cf_users2` table???

 

I'm sure this is simple, but I just don't know how  :P

 

any help is greatly(like always) appreciated  ;D

 

Regards ACE

How does this relate to the topic title?

 

You can try this:

 

$sqlzx = "UPDATE `cf_users`,`cf_users2` SET `cfusers`.`money`= `cfusers`.`money`+ `cfusers2`.`amount_supplydrop`*`cfusers2`.`amount_supplysize` WHERE cfusers.id = cfusers2.id";

 

Btw, in most cases the quotes aren't needed.

worked like a charm btherl, thanks  :D

 

Also, for the more complicated MySQL stuff, there's a dedicated board for that. A lot of MySQL pros who don't care much about PHP hang out there and will see your posts.

 

PhREEEk

 

I'll keep that in mind, cheers  :)

 

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.