Jump to content

[SOLVED] Mysql query and add results in field


acctman

Recommended Posts

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}' ");

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');
?>

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.