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
https://forums.phpfreaks.com/topic/165147-solved-radiogroup-from-mysql/
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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.