I’m having a hard time figuring out how to grab the list the cumulative totals of our site’s top 3 donors by adding up each donation they’ve ever given and seeing who’s given the most over the years.
So far I’ve gotten it to output the Top 3 single donations. I need help taking it that 1 step farther into totaling them all up for each user and then spitting out the top user.
[CODE]// TOP 3 SINGLE DONATIONS
$sql = ”
SELECT ROUND(p.gross) as total, u.uid, u.uname, p.tid
FROM “.$prefix.”_site_usrs AS u
INNER JOIN “.$prefix.”_paypal_donation AS p ON (u.uid=p.tid)
ORDER BY ROUND(p.gross) DESC LIMIT 3”;
$result = $db->sql_query($sql);
echo “Top 3 Donation Amounts”;
while(list($total, $uid, $uname, $tid) = $db->sql_fetchrow($result)){
echo “”.$uname.” – “.$total.” <br />”;
}