ffxpwns Posted May 21, 2012 Share Posted May 21, 2012 So there is this code I have here : http://pastebin.com/rwcN7FeJ and I need to find a way to incorporate this code that user Barand gave me $referName = mysql_real_escape_string($gateway_data['refer']); $query = "UPDATE users a INNER JOIN users b ON a.refer = b.nick SET a.refer = '', b.balance = b.balance + 5 WHERE b.refer = '$referName'"; mysql_query($query); But I havent the damnedest how to do that. If anyone could help me at all, it would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/262851-help-with-mysql-update/ Share on other sites More sharing options...
ffxpwns Posted May 21, 2012 Author Share Posted May 21, 2012 I must add, my table structure has columns called 'nick' (username) 'refer' (Who referred this person) and 'balance' There are a lot of other ones, but these are the ones that matter. So when someone signs up, they put in their referrers username and it does nothing. And when the referred user buys something, the referrer gets 5$. Here is my question. How would I write an UPDATE where the name in the refer field would award the referrer with +5 to balance, then it would clear the 'refer' field. I got the set refer to blank. Like this: +------+-------+------------+ | nick | refer | balance | +------+-------+------------+ | A | B | 0.00 | +------+-------+------------+ | B | C | 0.00 | +------+-------+------------+ A buys so B gets $5 added to his balance and the referrer is cleared from A, giving this after the update +------+-------+------------+ | nick | refer | balance | +------+-------+------------+ | A | | 0.00 | +------+-------+------------+ | B | C | 5.00 | +------+-------+------------+ Quote Link to comment https://forums.phpfreaks.com/topic/262851-help-with-mysql-update/#findComment-1347196 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.