MasterACE14 Posted December 4, 2007 Share Posted December 4, 2007 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 any help is greatly(like always) appreciated Regards ACE Link to comment https://forums.phpfreaks.com/topic/80101-solved-very-strange-values-in-mysql-columns-arent-what-they-are-suppose-to-be/ Share on other sites More sharing options...
btherl Posted December 4, 2007 Share Posted December 4, 2007 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. Link to comment https://forums.phpfreaks.com/topic/80101-solved-very-strange-values-in-mysql-columns-arent-what-they-are-suppose-to-be/#findComment-405939 Share on other sites More sharing options...
PHP_PhREEEk Posted December 4, 2007 Share Posted December 4, 2007 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 Link to comment https://forums.phpfreaks.com/topic/80101-solved-very-strange-values-in-mysql-columns-arent-what-they-are-suppose-to-be/#findComment-405940 Share on other sites More sharing options...
MasterACE14 Posted December 4, 2007 Author Share Posted December 4, 2007 worked like a charm btherl, thanks 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 Link to comment https://forums.phpfreaks.com/topic/80101-solved-very-strange-values-in-mysql-columns-arent-what-they-are-suppose-to-be/#findComment-405954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.