Jump to content

[SOLVED] RadioGroup from mysql


snowman2344

Recommended Posts

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
Share on other sites

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.