Page 1 of 1

radio buttons

Posted: Wed Mar 22, 2006 8:01 pm
by aceconcepts
Hi,

I have created a page that displays a list extracted from a mysql db. In each row i have a radio button.

When I view the page i am able to select all radio buttons. I would like to be able to just select one so if i try to select multiple radio buttons i can't, just the current one i have selected.

Thanks.

Posted: Wed Mar 22, 2006 8:05 pm
by walkekev
give me an example

Posted: Wed Mar 22, 2006 8:12 pm
by aceconcepts
http://www.lastminute.com/

On the home page there is a box titled 'Search by category'.

Notice that you cannot select more than one radio button.

How can I do this using php?

Thanks.

Posted: Wed Mar 22, 2006 8:14 pm
by feyd
name them all exactly the same and they will automaticaly group together.

Posted: Wed Mar 22, 2006 8:16 pm
by aceconcepts
This is how i have coded my list:

Code: Select all

<?php
//include "auth.inc.php";
//include "b2b_header.php";
//CONNECT TO SERVER AND DATABASE
session_start();
include "conn.inc.php";

$query = "SELECT * FROM delivery" ;

$result = mysql_query($query)
	or die(mysql_error());
?>
<html>
<body>
<table width="600" border="0">
  <tr bgcolor="#0099CC"> 
    <td width="414"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Destination</font></strong></td>
    <td width="103"> 
      <div align="center"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Duration</font></strong></font></div></td>
    <td width="103"> 
      <div align="center"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Price</font></strong></font></div></td>
    <td width="83"></td>
  </tr>
  <?php 
 while ($row = mysql_fetch_array($result)) {
	extract($row);
  echo "<tr bgcolor=\"#CAE0EE\"><td><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
  echo $del_destination;
  echo "</font></td>";
  echo "<td align=\"center\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
  echo $del_duration;
  echo "</td></font>";
  echo "<td align=\"center\"><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
  echo $del_price;
  echo "</td>";
  echo "<td align=\"center\"><br>";
?>
  <form name="form1" method="post" action="">
    <input type="radio" name="radiobutton" value="radiobutton">
  </form>
  <?php
 echo "</td></tr>";
  }
  ?>
</table>
</body>
</html>

Posted: Wed Mar 22, 2006 8:22 pm
by feyd
the form should span all the radio buttons. i.e. start before the table starts, and end after the table does.

Posted: Wed Mar 22, 2006 8:25 pm
by aceconcepts
wonderful!!!!

Thanks a lot for your help. Once again.