acctman Posted September 9, 2007 Share Posted September 9, 2007 hi i need to mysql query table rate_referrals then WHERE ref_userid = $userid and add up all the results in ref_points for the selected $userid Quote Link to comment Share on other sites More sharing options...
Barand Posted September 9, 2007 Share Posted September 9, 2007 SELECT SUM(ref_points) as totalpoints FROM rate_referrals WHERE ref_userid = $userid (moving to mysql forum) Quote Link to comment Share on other sites More sharing options...
acctman Posted September 9, 2007 Author Share Posted September 9, 2007 SELECT SUM(ref_points) as totalpoints FROM rate_referrals WHERE ref_userid = $userid (moving to mysql forum) so totalpoints is just a place holder for the sum? something like this would work? $en['totalpts'] = mysql_query("SELECT sum(ref_points) totalpoints FROM `rate_referrals` WHERE `ref_userid` = '{$userid}' "); Quote Link to comment Share on other sites More sharing options...
Barand Posted September 9, 2007 Share Posted September 9, 2007 something like this would work? $en['totalpts'] = mysql_query("SELECT sum(ref_points) totalpoints FROM `rate_referrals` WHERE `ref_userid` = '{$userid}' "); No. <?php $res = mysql_query("SELECT sum(ref_points) as totalpoints FROM `rate_referrals` WHERE `ref_userid` = '{$userid}' "); $en['totalpts'] = mysql_result($res,0,'totalpoints'); ?> Quote Link to comment 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.