Having problems adding the total of one column. Being a noob, I think I'm not fully understanding something and that's why it's not working for me. My query results in two returns.
They are:
10 $200
10 $150
I want to add the dollar amounts (referral_actual_fee). I read somewhere that I would need to use array_sum, but I can't get it to work. I finally learned how to print the array, so I could see it, but that didn't do me any good either. Here is the array for you in case it matters:
Array ( [0] => 03/17/10 [referral_pay_date] => 03/17/10 [1] => 200 [referral_actual_fee] => 200 )
Array ( [0] => 09/10/10 [referral_pay_date] => 09/10/10 [1] => 150 [referral_actual_fee] => 150 )
Finally, I left out the part where I was trying to use array_sum 'cause nothing is working. If anyone can plug it in for me, so I can see how to do this I would be grateful.
Here's my code:
Code: Select all
$requestor = 'Squashers';
$query = "SELECT referral_pay_date, referral_actual_fee FROM users WHERE affiliate = '".$requestor."' " ;
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
if ( substr(''.$row['referral_pay_date'].'', -2 ) == 10 ) {
echo substr(''.$row['referral_pay_date'].'', -2) ;
echo "$".$row['referral_actual_fee']. "<br> \n"; // THIS IS THE COLUMN I'M TRYING TO ADD (SUM)
}
}