I want to get the value and do calculations based off what the user selects.
<?php
$err = "";
// I used an associative array because the items have a price that goes with them.
$food = array("Bananas"=>"3", "Grapes"=>"4", "Cucumbers"=>"2","Carrots"=>"2");
foreach($food as $f => $f_value){
echo '<input type ="checkbox">'.$f." - $".$f_value.'<br>';
}
if (isset($_POST["$f_value"])) {
echo $_POST['$f_value'];
} else {
$err = "Food has been selected";
}
?>
When I select and item with the code I have it prints my error statement.
Aucun commentaire:
Enregistrer un commentaire