dynamic readio button loop - assigning name and passing
Posted: Wed Sep 14, 2005 7:31 am
Hi!
So I'm creating an online form that pulls information from a database and inserts part of it into a series of radio buttons. The issue is that in order for the radio buttons to function independent of each other, each one needs a unique name. I've suceeded in creating an incrementing variable that I attach to the beginning of each radio button as it goes through the loop, but I can't figure out how to get the data to the next page or into the database...
Code:
This comes out in the page source as:
I'm basically trying to figure out what the variable that gets passed looks like and how to play with it (at least print each passed value out to begin with).
Anyone have any ideas? Thanks
So I'm creating an online form that pulls information from a database and inserts part of it into a series of radio buttons. The issue is that in order for the radio buttons to function independent of each other, each one needs a unique name. I've suceeded in creating an incrementing variable that I attach to the beginning of each radio button as it goes through the loop, but I can't figure out how to get the data to the next page or into the database...
Code:
Code: Select all
while($row = mysql_fetch_assoc($result))
{ //this loops out the data into multiple columns
print("<td align='left' style='padding: 3px;'>");
print("<textarea name='description[]' rows='2' cols='20'>$row[description]</textarea><br /> \n");
if(trim($row[success_flag]) == "success")
{
echo ('<input type="radio" name="success_fail[]'.$i.'" value="'.$i.'success" CHECKED/> Success <br>');
echo ('<input type="radio" name="success_fail[]'.$i.'" value="'.$i.'failure"/> Failure <br>');
print("</td> \n\n");
$i++;
}
else if(trim($row[success_flag]) == "failure")
{
echo ('<input type="radio" name="success_fail[]'.$i.'" value="'.$i.'success"/> Success <br>');
echo ('<input type="radio" name="success_fail[]'.$i.'" value="'.$i.'failure" CHECKED/> Failure <br>');
print("</td> \n\n");
$i++;
}
else
{
echo ('<input type="radio" name="success_fail[]'.$i.'" value="'.$i.'success"/> Success <br>');
echo ('<input type="radio" name="success_fail[]'.$i.'" value="'.$i.'failure"/> Failure <br>');
print("</td> \n\n");
$i++;
}
}Code: Select all
<input type="radio" name="success_fail[]1" value="1success" CHECKED/> Success <br>
<input type="radio" name="success_fail[]1" value="1failure"/> Failure <br></td>
...code...
<input type="radio" name="success_fail[]2" value="2success" CHECKED/> Success <br>
<input type="radio" name="success_fail[]2" value="2failure"/> Failure <br></td>
<input type="radio" name="success_fail[]3" value="3success"/> Success <br>
<input type="radio" name="success_fail[]3" value="3failure" CHECKED/> Failure <br></td>Anyone have any ideas? Thanks