I created an HTML table containing radio fields using a multidimensional array.
How can I get the selected values from the form submission?
My current code:
$cakedata = array(
array("shape" => "Heart", "flavor" => "Chocolate", "toppings" => "Cookies"),
array("shape" => "Rectangle", "flavor" => "Vanilla", "toppings" => "Spun-sugar Flowers"),
array("shape" => "Square", "flavor" => "Lemon", "toppings" => "Mini Chocolate Candies"),
array("shape" => "Round", "flavor" => "Cheesecake", "toppings" => "Marshmallows")
);
echo "<form action = 'diycake.php' method = 'post'>";
echo "<table><table border = '1'>";
echo "<tr>";
echo "<th> Cake Shape </th>";
echo "<th> Cake Flavor </th>";
echo "<th> Cake Toppings </th>";
$i = 0;
foreach($cakedata as $row => $innerArray){
foreach($innerArray as $innerRow => $value){
if($i==0){
echo "<tr>";
}
echo "<td><input type ='radio' name ='radio".$i."'>".$value."</td>";
if($i==2){
echo "</tr>";
$i=-1;
}
$i++;
}
}
echo "</tr>";
echo "</table><br>";
echo "<input type = 'submit' name = 'submit' value = 'Submit'>";
echo "</form>";
echo '<pre>'; print_r($cakedata); echo '</pre>';
How do I receive the user's selections?
diycake.php