Jump to content

Populating radio buttons from an SQL query result set


varun_146100

Recommended Posts

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.

As you loop through the records returned by your query have something like this:

echo '<input type="checkbox" name="dates" value="'.$row['id'].'>'.$row['startdate'].' - '.$row['enddate'];

 

You need to give them all the same name otherwise you'll be selecting one and if selecting another the other won't de-delect.

 

Read them with this:

$chosen=$_POST['dates'];

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.