Hi,
Am very new to PHP and am stuck up right now.
I have an SQL query that returns me a result set having 2 columns (Start Date , End Date)
1=> This result set needs to be generated on the selection of an item(Id) from the options in a select box.
2=> I need this result set to be displayed in radio buttons.
The user can then select one of the radio button options.He can then submit the data.
I need to know how can I achieve 1 & 2.
Please help me on this one.Will really appreciate that.
Populating radio buttons from an SQL query result set
Moderator: General Moderators
-
varun_146100
- Forum Newbie
- Posts: 3
- Joined: Wed Oct 22, 2008 3:48 am
Re: Populating radio buttons from an SQL query result set
varun_146100 wrote:Hi,
Am very new to PHP and am stuck up right now.
I have an SQL query that returns me a result set having 2 columns (Start Date , End Date)
1=> This result set needs to be generated on the selection of an item(Id) from the options in a select box.
2=> I need this result set to be displayed in radio buttons.
The user can then select one of the radio button options.He can then submit the data.
I need to know how can I achieve 1 & 2.
Please help me on this one.Will really appreciate that.
I am not really sure what you mean...but it sounds like you need this..
Code: Select all
//set the name of your button...if you make radio buttons with the same name it gives you an option between the two
$name = 1;
$results = mysql_query( "SELECT * FROM details WHERE `set` = '".$set."'" );
while( $row = mysql_fetch_array( $results ) )
{
$result = mysql_query( "SELECT * FROM details WHERE `id` = '".$row[id]."'" );
while( $rows = mysql_fetch_array( $result ) )
{
echo "<input type='radio' name='$name'>$rows[name]";
}
//after you get a group of buttons, change the name of the next group of buttons you get by adding a number to it.
$name++;
}