SO:
Die Include Datei:
PHP
<?php
$pizzas = array(
array(
'name' => 'Pizza Margherita',
'bild_url' => 'Pizza Bilder/Margh.jpg',
'groessen' => array(
array(
'text' => 'Klein (2,50€)',
'preis' => 2.50,
),
array(
'text' => 'Normal (3,50€)',
'preis' => 3.50,
),
array(
'text' => 'Groß(5,00€)',
'preis' => 5.00,
),
),
),
array(
'name' => 'Thunfisch Pizza',
'bild_url' => 'Pizza Bilder/Thuna.jpg',
'groessen' => array(
array(
'text' => 'Klein (3,00€)',
'preis' => 3.00,
),
array(
'text' => 'Normal (4,00€)',
'preis' => 4.00,
),
array(
'text' => 'Groß(6,00€)',
'preis' => 6.00,
),
),
),
);
array(
'name' => 'Pizza Hawaii',
'bild_url' => 'Pizza Bilder/Hawa.jpg',
'groessen' => array(
array(
'text' => 'Klein (3,00€)',
'preis' => 3.00,
),
array(
'text' => 'Normal (4,00€)',
'preis' => 4.00,
),
array(
'text' => 'Groß(6,00€)',
'preis' => 6.00,
),
),
);
array(
'name' => 'Schinken Pizza',
'bild_url' => 'Pizza Bilder/Schin.jpg',
'groessen' => array(
array(
'text' => 'Klein (3,00€)',
'preis' => 3.00,
),
array(
'text' => 'Normal (3,50€)',
'preis' => 3.50,
),
array(
'text' => 'Groß(5,50€)',
'preis' => 5.50,
),
),
);
$pizza_individuell = array(
'grundpreis' => 2.00,
'oliven' => 1.00,
'speck' => 1.00,
'schinken' => 1.00,
'ananas' => 1.00,
'eier' => 1.00,
'meeresfrüchte' => 1.00,
);
$getraenke = array(
'alkoholisch' => array(
array(
'text' => 'Krombacher',
'info' => '(1Liter)(2,00€), Anzahl',
'preis' => 2.00,
array(
'text' => 'Weiß Wein',
'info' => '(1Liter)(5,00€), Anzahl',
'preis' => 5.00,
array(
'text' => 'Rot Wein',
'info' => '(1Liter)(5,00€), Anzahl',
'preis' => 5.00,
),
),
),
),
);
'ohne_alkohol' == array(
array(
'text' => 'Coca Cola',
'info' => '(1Liter)(1,50€), Anzahl',
'preis' => 1.50,
array(
'text' => 'Fanta',
'info' => '(1Liter)(1,50€), Anzahl',
'preis' => 1.50,
array(
'text' => 'Sprite',
'info' => '(1Liter)(1,50€), Anzahl',
'preis' => 1.50,
array(
'text' => 'Mineralwasser',
'info' => '(1Liter)(1,00€), Anzahl',
'preis' => 1.00,
),
),
),
),
);
?>
Alles anzeigen
Die Eingabe Datei:
PHP
<?php
include 'pizzadaten.inc.php';
foreach ($pizzas as $pizza_id => $pizza)
{
print '
<input type="checkbox" name="pizza[' . $pizza_id . ']" value="1">' . $pizza['name'] . ', Anzahl
<input type="text" name="pizza_' . $pizza_id . '_anzahl" size="1"> <a href="' . $pizza['bild_url'] . '">BILD</a><br>';
foreach ($pizza['groessen'] as $pizza_groesse_id => $pizza_groesse)
{
print '<input type="radio" name="pizza_' . $pizza_id . '_groesse" value="' . $pizza_groesse_id . '">' . $pizza_groesse['text'] . ' ';
}
print '
';
}
?>
Alles anzeigen
Nur sieht die Seite etwas komisch aus.
Also die Anordnung der Eingabefelder. Sieht nicht ordentlich aus.
Liegt wahrscheinlich an der foreach Schleife oder?