I have multiple radio buttons that are linked together. I want to set the value of each radio button based on whether it is clicked/set or not
<td><br><input type="radio" name="meal1" <?php if (isset($meal1)){
echo "checked", "value = '1'";
} else {
echo "value = '0'";
}
?>>
</td>
<td><br><input type="radio" name="meal1" <?php if (isset($meal2)){
echo "checked", "value = '1'";
} else {
echo "value = '0'";
}
?>>
</td>
<td><br><input type="radio" name="meal1" <?php if (isset($meal3)){
echo "checked", "value = '1'";
} else {
echo "value = '0'";
}
;?>>
</td>
<td><br><input type="radio" name="meal1" <?php if (isset($meal4)){
echo "checked", "value = '1'";
} else {
echo "value = '0'";
}
;?>>
</td>
This code is just to show the output of each of the radio buttons
if(isset($_POST['order'])){
if(!isset($_POST['meal1'])){
echo "Radio buttons not set.";
} else {
$meal1 = $_POST['meal1'];
$meal2 = $_POST['meal1'];
$meal3 = $_POST['meal1'];
$meal4 = $_POST['meal1'];
print_r($meal1);
print_r($meal2);
print_r($meal3);
print_r($meal4);
}
When I execute the code below, after clicking on of the radio buttons. The output is 0,0,0,0. I would like the output to 1,0,0,0 Since I have clicked the first radio button.