Grazie per il recente l'aiuto offerto generosamente dai moderatori.
Ho un problema ch non riesco a risolvere.
un from html collegato ad un programma php col GET.
Non riesco a far segliere il 'drink' in base al 'dinner' scelto utilizzando else/if.
Ho impostato una costante 'drink_price' ma vorrei che il programma potesse mettre nella ricevuta 'receipt' il drink scelto automaticamente in base alla cena 'dinner'.
di seguito il codice:
(.php file)
[/list]
- Receipt Dienner
<?
$dinner = $_GET["dinner"];
$red_wine = 3;
$white_wine = 4;
$coca_cola = 2;
// giving to 3 drinks choises a value each
if ($dinner == "steak") {$drink = "red wine";}
else if ($dinner == "salmon") {$drink = "white wine";}
else if ($dinner == "barbecue_pork") {$drink = "red wine";}
else if ($dinner == "chicken") {$drink = "coca cola";}
// at the dinner choise a drink is attached (doesn't work yet!)
$drink_price = 3;
// setting to a drink a constant price
$subtotal = ($dinner + $drink_price);
// calculating subtotal of the chosen dinner.
$tax = $subtotal * 0.08; // calculating tax from the subtotal
$tip = $subtotal * 0.15; // calculating tip from the subtotal
$grand_total = $subtotal + $tax + $tip // calculating grand total
?>
<ul>- dinner: $<? echo $dinner; ?>
- drink: $<? echo $drink_price; ?>
</br>- tax: $<? echo $tax; ?>
- tip: $<? echo $tip; ?>
</br>- TOTAL: $<? echo $grand_total; ?>
(.html form)
<body>
<h2>Choosing your dinner</h2>
<form method="GET" action="lab3dinner.php">
<select name="dinner">
<option value="">Choose the dinner</option>
<option value="7 Steak">steak</option>
<option value="9 Salmon">salmon</option>
<option value="5 Barbecue pork">barbecue pork</option>
<option value="3 Chicken">chicken</option>
</select>
<input type=submit value="SUBMIT" />
</form>
</body>
Grazie per ogni suggerimento