Hi, I need to find a way of outputting the total (sum) values of three decimal fields in a mySQL table using PHP.
I thought this might be a good query string to use:
$query = "SELECT Nett, SUM(Nett), VAT, SUM(VAT), Gross, SUM(Gross) from Customers WHERE Name LIKE '$name'";
This will act on data from a previous page where the user selects the Customer from a dropdown- and this produces the $name variable.
Nett, VAT and Gross are the three fields. There are about 50 or more values for each, for example Nett values might be -123.54, -234.76 and so on. For each of these three fields, I want to be able to add them all up (for that specified Customer name) so we end up with the added-up values of all three fields in the table that fit the criteria (i.e which are for that Customer).
Assuming the query is ok (and it probably isn’t), I need to find a way of getting PHP to do the work, and output a variable which equals the respective totals. What would be the best way of doing this?