Jump to content

Radio Button Group


sepoto
 Share

Recommended Posts

I have code that creates radio buttons in a form. Right now each radio button has a unique name. Is there not a way to make it so the radio buttons are grouped or something of that nature?

<?phpmysql_connect('127.0.0.1','root','**********');@mysql_select_db('methane') or die( "Unable to select database");$query="SELECT DISTINCT import_date FROM planning ORDER BY import_date ASC";$result=mysql_query($query);$num=mysql_numrows($result);?><html><head><title>Select Data Set</title></head><body><form action="displaydata.php" method="post"><div style='border: solid 1px black;'><?php$X=0;while ($X < $num) {$importdate=mysql_result($result,$X,"import_date");echo "<input type = 'Radio' Name ='" . $X . "' Value='" . $importdate . "' >";echo $importdate . "<br>";$X++;}?><input type = 'Submit' Name = 'Go' Value = 'Get Record Set'></form></div></body></html>

Edited by sepoto
Link to comment
Share on other sites

I am not sure what do you mean by group? in basis of what you want to group?

Link to comment
Share on other sites

I am not sure what do you mean by group? in basis of what you want to group?
echo "<input type = 'Radio' Name ='radio' Value='" . $importdate . "' >";

I found out that if you call all of them radio that a call to $_POST["radio"] will return the Value of the one selected which in these cases is $importdate.

Link to comment
Share on other sites

thats how radio button works, you can choose one option from multiple option for particular name var

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...