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 Quote Link to comment 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++; } ?> Quote Link to comment 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; } Quote Link to comment Share on other sites More sharing options...
snowman2344 Posted July 8, 2009 Author Share Posted July 8, 2009 Thanks that worked great Quote Link to comment 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 ??? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.