Hey there,
Ik got a function which creates an array based on form fields on the page before.
Now with that array i want a simple foreach kind a thing in the template, i know i'm close, but could anyone help me a step further?
Here's the php
if ($_POST['Intermediair_250'] > 0) {
$producten[]['product'] = 'Intermediar pakket 250';
$producten[]['prijs_totaal'] = $_POST['Intermediair_250'] * 2697;
$producten[]['prijs_per_stuk'] = 2697;
}
if ($_POST['Intermediair_1000'] > 0) {
$producten[]['product'] = 'Intermediar pakket 1000';
$producten[]['prijs_totaal'] = $_POST['Intermediair_1000'] * 7188;
$producten[]['prijs_per_stuk'] = 7188;
}
$totaalprijs = 0;
foreach ($producten as $product) {
$totaalprijs = $totaalprijs + $product['prijs_totaal'];
}
$doProducten = new DataObjectSet();
$doProducten->producten = new ArrayData($producten);
$data = array(
"Title" => "Mijn bestelling",
"producten" => $doProducten,
"totaalprijs" => $totaalprijs
);
And then in the template :
<% control producten %>
<tr>
<td class="icon"><img src="empex/images/shoppingcart.jpg" width="25" height="23" /></td>
<td class="Producten">$product</td>
<td class="Aantal"></td>
<td class="Categorie"></td>
<td class="Credits"></td>
<td class="Geldigheid"></td>
</tr>
<% end_control %>
so i want to iterate producten, but how?
Thanks!