Getting values from radio buttons named dynamically
I have "n" number of rows being returned by a sql statement. Works great. For every row returned, I would like the user to pick an option (either option 'a' or option 'b')
As standard practice a while loop is used to iterate through each row, and I attempt to name my options by the row number. However, I run into problems when I attempt to get the value of the radio button the user has selected.
I can't seem to dynamically get the value of the radio button named 1 in the first loop (or any loop with it's appropriate name) of the where clause. Or in other words: I'm looking to see why 'choice' is not getting the value selected by the user in
Code snippet here:
$counter = 1;
while($row = mysql_fetch_array($result))
echo "<form action='updatepics.php' method='post'>";
echo "<input type='radio' name='m" . $counter . "' value= ". $row['f_id'] ."> " . $row['Favorite'];
echo "<input type='hidden' name='game' value=" . $counter . ">";
echo " vs " . $row['Underdog'] ." ";
echo "<input type='radio' name='m" . $counter . "' value= ". $row['d_id'] ."> ";
echo "<input type='hidden' name='choice' value=" . $_GET["m" . $counter] . " >";
echo "<input type='submit' value='Make Choice'>";
echo " " . $_POST['player'] . " picks: ";
echo " " . $_POST['choice'] ;
output of updatepics.php...
Game 1 granny picks:
Notice 'choice' is null
Wow, I can't believe you should wait this long to have the moderator review the question before posting. With such a long lag-time, I was able to work through different approaches to get this to work.
I dumped the idea of dynamically radio buttons, and just went with static names. It worked.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread