hello, got this annoying issue with the sum of values, I am displaying all the DepositCost in the selected date, year… grouped by months
January
February
….
December
so I am adding them together using SUM, but I dont want to add the value when commission is 0 and not quite sure how to do it as its always taking the first record and applying changes to others, here it is mysql query and below php code
mysql_select_db($database_franchisecms, $franchisecms);
$query_enquires = sprintf(“SELECT MONTH(TrailDate), commission, SUM(DepositCost), SUM(DepositCost1) FROM appointment WHERE YEAR(TrailDate) = ‘2011’ GROUP BY YEAR(TrailDate), MONTH(TrailDate)”);
$enquires = mysql_query($query_enquires, $franchisecms) or die(mysql_error());
$row_enquires = mysql_fetch_assoc($enquires);
$totalRows_enquires = mysql_num_rows($enquires);
[code=html]<?php do { ?>
<?php
if ($row_enquires[‘commission’] != 0) {
$commission= 75;
} else {
$commission= 20;
}
?>
<?php
// here I want to add only commission when its exist
echo $deposit = $row_enquires(‘SUM(DepositCost)’) + $commission;
// here I want to add only commission when its non exist
echo $deposit1 = $row_enquires(‘SUM(DepositCost1)’) + $commission;
?>
<?php } while ($row_enquires = mysql_fetch_assoc($enquires)); ?>
I don’t know is that make any sense but I can explain in more details. Thank you