
Incluir radiobutton en tabla y conocer la opcion seleccionada.
Publicado por Bladimir (88 intervenciones) el 15/04/2015 12:48:25
Hola a todos. Estoy desarrollando una aplicacion con php y html. El asunto es que necesito llenar una tabla en html a partir de una consulta select que se hace a una tabla mysql. Ya he podido llenar la tabla. Lo que no he podido es incluir un radiobutton para que el usuario pueda seleccionar una opcion y hacer luego una segunda consulta a la bd y extraer la informacion de eses registro. El codigo php que uso es le sigiente:
Gracias de antemano. saludos.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$busqued = isset($_POST['criterio']) ? $_POST['criterio'] : null ;
$seleccion = isset($_POST['selecc']) ? $_POST['selecc'] : null ;
$link = mysqli_connect("localhost", "root", "", "Consulta") or die ('Error de conexion: ' . mysqli_error());
if (strlen($busqued)>1){
if ($seleccion=="cedula"){
$result= mysqli_query($link,"SELECT CI,NOMBRE,APELLIDO, EDAD FROM PACIENTES WHERE CI='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>CI</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</th> <th>Seleccionar</th></tr>";
while($row = mysqli_fetch_array($result)){
echo " <tr> <td>".$row[0]."</td> <td>".$row[1]."</td> <td>".$row[2]."</td> <td>".$row[3]."</td></tr>";
}
echo "</table>";
}else if ($seleccion=="nombre"){
$result= mysqli_query($link,"SELECT CI,NOMBRE,APELLIDO, EDAD FROM PACIENTES WHERE NOMBRE='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>CI</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</th> <th>Seleccionar</th> </tr>";
while($row = mysqli_fetch_array($result)){
echo " <tr> <td>".$row[0]."</td> <td>".$row[1]."</td> <td>".$row[2]."</td> <td>".$row[3]."</td> </tr>";
}
echo "</table>";
}
else if ($seleccion=="apellido"){
$result= mysqli_query($link,"SELECT CI,NOMBRE,APELLIDO, EDAD FROM PACIENTES WHERE APELLIDO='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>CI</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</th> <th>Seleccionar</th></tr>";
while($row = mysqli_fetch_array($result)){
echo " <tr> <td>".$row[0]."</td> <td>".$row[1]."</td> <td>".$row[2]."</td> <td>".$row[3]."</td></tr>"; } echo "</table>";
}
}
mysqli_close($link);
?>
Gracias de antemano. saludos.
Valora esta pregunta


0