Am building a vehicle fleet management system, srevice cost is added each time a vehicle is serviced.
Now, lets say vehicle A have been service 8 time, B 5 times, C 10 times ...
I want to show the SUM(cost) for servicing each vehicle at the same time.
I wrote this, but this,but it only select the first service cost of each row like i want it, BUT IT IS NOT SUMING THEM UP
$accra = mysql_query("SELECT *, SUM(service_price) FROM serv_entry GROUP BY svreg");
while($row = mysql_fetch_assoc($accra))
{
$id = $row['id'];
$service_price = $row['service_price'];
$receipt = $row['receipt'];
$svreg = $row['svreg'];
echo "
<table align='left' class='table table-striped table-bordered'>
<tbody>
<tr>
<td width='30%'>$svreg</td>
<td width='30%'>$currency $service_price</td>
<td width='30%'>$receipt</td>
</tr>
</tbody>
</table>
";
}