I have a mysql table
service_charges
id service_name service_charges
I use a mysql query like
select service_name service, service_charges,count(service_name)as unit
from service charges group_by service
in php file I am using
foreach(services as service){
echo $service['service'];
echo $service['service_charges'];
echo $service['unit'];
$service_charges_total = (($service['service_charges'])*($service['unit']));
echo $sevice_charges_total;
}
I am getting the result like this:
Now How can I get the total for $service_charges_total(amount column) i.e. I want a total of 4200+1200 + 350 = 5750.
Thanks.
You can do it at php at your function like this
$total=0;
foreach(services as service)
{
echo $service['service'];
echo $service['service_charges'];
echo $service['unit'];
$service_charges_total = (($service['service_charges'])*($service['unit']));
echo $sevice_charges_total;
$total+=$sevice_charges_total;
}
echo $total;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With