Hey guys
I'm having a little problem with a query, I've been at it for hours and I'm running out of time.
My table looks like this (kind of) (name & amount_payed)
| fred |$5.00
| fred |$15.00
| Mary |$10.00
| Mary |$2.00 and so on and on..
What I'd like to do is end up with a result like
Fred $20.00
Mary $12.00
Adding up all the totals in the 'amount_payed' column and displaying the top 5 people who have payed the most.
This is what I have so far
function top5()
{
$sql = mysql_query("SELECT * FROM paypal WHERE private='False' ORDER BY SUM(amount_payed) DESC LIMIT 5");
while($top5 = mysql_fetch_array($sql))
{
$top5_name = $top5['name'];
//*********I'm pretty much stuck from here on**************
}
}
Any help would be appreciated