I have a db with 3 tables. Table A contains goods with descriptions and prices and so on. There 2 columns of prices: first price and sales price. Table B contains customer details and table C the orders. I print to page with "SELECT goods.,customers., orders.* FROM goods,customers,orders WHERE...." 'customers' and 'orders' contain both a column for the bill number, so if a customer orders, there will be a new row in 'orders' for every item bought with the same bill number in the column. How can I show the order with the customer details and the bill number showing once only and then just listing the appropriate ordered items? In order to calculate the total of an order, I did this:
if(empty($row["PriceSale"])||$row["PriceSale"]=='0.00')
{
$Price=$row["Price"];
}else{
$Price=$row["PriceSale"];
}
$sum = 0;
$amount = $row["Amount"];
$NPrice = $Price*$amount; //for total of one item (per row)
$sum = ($sum + $NPrice); //if this line is not there, then the $total_sum will have no effect
$sum = number_format($sum,2);
Now when I do:
$total_sum += str_replace(",", "", $sum);
then it calculates the price total, but it also shows me the 'Notice: Undefined variable: $total_sum....' When I do $totalsum=0 it will calculate wrong. So, how can this be done?