Hi !
I’m new to php and try to devellop a simple application that would allow the user to classify various dishes by using radio buttons. I'm a bit lost :(
My code is as follows (I’ve already got help to achieve it, but can’t go further). The first part is correct. But the second one, which consists in showing the dishes in the corresponding section (eg:
Sugar:
- ,
- Slat:
- ,
- Spicy :
- ), do not work.
- Thank you very much for your help!!
- Raf
<?php
$dish = array('soup', 'starter', 'meal', 'dessert');
echo '<form action="" method="post">
<table>
<tr>
<th>Dish</th>
<th>Sugar</th>
<th>Salt</th>
<th>Spicy</th>
</tr>
';
foreach ($dish as $value){
echo '<tr>
<td>'.$value.'</td>
<td><input type="radio" value="sugar" name="dish['.$value.'][]" /></td>
<td><input type="radio" value="salt" name="dish['.$value.'][]" /></td>
<td><input type="radio" value="spicy" name=dish['.$value.'][]" /></td>
</tr>';
}
echo '<tr><td colspan="4"><input type="submit" name="env" value="submit" /></td></tr></table></form>';
?>
<strong> Sugar : </strong>
<?php /* From this point it doesn’t work any more*/
foreach($_POST['dish'] as $selection)
{
echo($selection == "sugar") $value ;
}
?>