Right now i have this piece of code running:
$count = 0;
foreach ($products as $key => $product){
$number = isset($_POST[$key])?$_POST[$key]:'';
if (!$number){
$count++;
echo "";
} else {
echo "<tr>";
echo "<td>";
echo $product;
echo "</td>";
echo "<td>";
echo $number;
echo "</td>";
echo "<td>";
$price = $prices[$count]* $number;
echo "€ ", $price;
echo "</td>";
echo "</tr>";
$count++;
}
}
But now i added a 3rd row (my first row is just the <th>
's) beneath that one looking like this:
echo "<tr>";
echo "<td>";
echo "Totaal";
echo "</td>";
echo "<td>";
echo $totalproducts;
echo "</td>";
echo "<td>";
echo $totalprice;
echo "</td>";
echo "</tr>";
As you can see i placed 2 $total... in this row where as you can guess need to come the total products ordered and total price of those products.
My problem is that i don't really know how to let it sum up all the $price and place this in $totalprice and sum up all $number and place it inside the $totalnumber. I know it's a basic question but it has been a long time ago since i actually worked with php. And i'm stuck on this.
I appreciate any help on this matter, thanks in advance!