Ver Mensaje Individual
  #4 (permalink)  
Antiguo 01/01/2011, 21:36
chuchufuentes
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
solucionado: Saber cual esta Check Radio Button (DB)

aquí esta el código


<form method='post' ACTION ='radiobtosql.php'>
<HTML>
<head>
<title>Radio Buttons</title>
</head>
<body>
<?php
$selected_radio="";
$servidor ="localhost"; // host
$usuario ="root";
$clave ="";
$basedatos ="abm"; // Indicar una Base de datos.

if (isset($_POST['click'])) {

$selected_radio = $_POST['gender'];

}

$conexion = mysql_connect($servidor, $usuario, $clave) or die(mysql_error());
mysql_select_db($basedatos, $conexion) or die(mysql_error());

$SQLconsulta="SELECT * FROM tabla_padre";
$recordset = mysql_query($SQLconsulta,$conexion) or die(mysql_error());
while ($med = mysql_fetch_array($recordset)) {
$mid = $med['id'];
$mname = htmlspecialchars($med['item_texto']);

?>
<td><INPUT TYPE = 'Radio' Name ='gender' value="<?php echo $mid;?>" <?php if($selected_radio==$mid){echo 'checked="checked"';} ?>><?php echo $mname;?></td>
<?php

}

?>
<input type="submit" value="Seleccione 1 opcion" Name = "click"/>
</FORM>
</HTML>