how do i get total values in a row by grouping into diffrent categories.

here is my code bt its getting oll totals in a row for now..
<?php require_once('connect.php'); ?>

<?php

$query="Select Amountspent from Moneyout";

$result=mysql_query($query);

$total=0;
while($row=mysql_fetch_array($result))
{
$total=$total + $row;
}

echo "Total is:" . $total;

?>


the colums are, Amountspent,Category,Financialyear and Financialmonth...i want it to group by the Amountspent,Category,Financialyear and Financialmonth..

please help

DUPLICATE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.