nats Posted December 26, 2008 Share Posted December 26, 2008 I want to be able to create radio buttons in my form dynamically. I have a database which has a table with some names in it, so I want to be able to create a radio button for each name I find in the table. Pretend that there are 3 names, then when I open the form I should be able to see 3 radio buttons: ¤ name 1 ¤ name 2 ¤ name 3 How do I do this ? Can anyone please suggest some useful links or provide some help with the code... Link to comment https://forums.phpfreaks.com/topic/138465-dynamic-radio-buttons/ Share on other sites More sharing options...
Flames Posted December 26, 2008 Share Posted December 26, 2008 <form stuff> <?php $sql = "SELECT * FROM tbl_name WHERE ...='...'"; $query = mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_assoc($query)) { echo $row['name'] . "<input type=\"radio\" name=\"name\" value=\"".$row['name']."\">"; } ?> </form> Link to comment https://forums.phpfreaks.com/topic/138465-dynamic-radio-buttons/#findComment-723963 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.