snowman2344 Posted July 8, 2009 Share Posted July 8, 2009 How do i show a RadioGroup based on a mysql value. I have a table in mysql with fields ID, Title, Desc, Outof Here is what i want if the number in the Outof is 10 i want to show 10 radio buttons in a group with the group name being Title EG <input type="radio" name="Title1" value="1" id="Title1_1"/>1 <input type="radio" name="Title1" value="2" id="Title1_2"/>2 <input type="radio" name="Title1" value="3" id="Title1_3"/>3 <input type="radio" name="Title1" value="4" id="Title1_4"/>4 <input type="radio" name="Title1" value="5" id="Title1_5"/>5 <input type="radio" name="Title1" value="6" id="Title1_6"/>6 <input type="radio" name="Title1" value="7" id="Title1_7"/>7 <input type="radio" name="Title1" value="8" id="Title1_8"/>8 <input type="radio" name="Title1" value="9" id="Title1_9"/>9 <input type="radio" name="Title1" value="10" id="Title1_10"/>10 Link to comment https://forums.phpfreaks.com/topic/165147-solved-radiogroup-from-mysql/ Share on other sites More sharing options...
asmith Posted July 8, 2009 Share Posted July 8, 2009 <?php for ($i = 1; $i <= $Outof; $i++) { echo '<input type="radio" name="Title1" value="'.$i.'" id="Title1_'.$i.'"/>'.$i; $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/165147-solved-radiogroup-from-mysql/#findComment-870814 Share on other sites More sharing options...
Philip Posted July 8, 2009 Share Posted July 8, 2009 <?php for ($i = 1; $i <= $Outof; $i++) { echo '<input type="radio" name="Title1" value="'.$i.'" id="Title1_'.$i.'"/>'.$i; $i++; } ?> That last $i++ isn't needed for ($i = 1; $i <= $Outof; $i++) { echo '<input type="radio" name="Title1" value="'.$i.'" id="Title1_'.$i.'"/>'.$i; } Link to comment https://forums.phpfreaks.com/topic/165147-solved-radiogroup-from-mysql/#findComment-870823 Share on other sites More sharing options...
snowman2344 Posted July 8, 2009 Author Share Posted July 8, 2009 Thanks that worked great Link to comment https://forums.phpfreaks.com/topic/165147-solved-radiogroup-from-mysql/#findComment-871031 Share on other sites More sharing options...
snowman2344 Posted July 8, 2009 Author Share Posted July 8, 2009 I want to mark as solved but i cannot find the link ??? Link to comment https://forums.phpfreaks.com/topic/165147-solved-radiogroup-from-mysql/#findComment-871038 Share on other sites More sharing options...
asmith Posted July 8, 2009 Share Posted July 8, 2009 lol for some reason I forgot I'm in for loop. I thought its a while loop XDD Link to comment https://forums.phpfreaks.com/topic/165147-solved-radiogroup-from-mysql/#findComment-871297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.