<?php
$busqued = isset($_POST['criterio']) ? $_POST['criterio'] : null ;
$seleccion = isset($_POST['selecc']) ? $_POST['selecc'] : null ;
if (strlen($busqued)>1){
if ($seleccion=="cedula"){
$link = @mysql_connect("localhost", "root", "") or die ('problema conectando porque :' . mysql_error());; //Conectar con el servidor
$basedatos = "Consulta";
mysql_select_db($basedatos, $link);
echo "<h4 align='center'>Bien hasta aqui</h4>";
$result= mysql_query("SELECT CI, NOMBRE, APELLIDO FROM PACIENTES WHERE CI='$busqued'",$link);
while($row = mysql_fetch_array($result)) {
printf("<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR><TD> <B>Nombre</B></TD> <TD> <B>Apellidos</B> </TD></TR>") ;
printf("<tr><td> %s</td> <td> %s </td></tr>", $row["NOMBRE"], $row["APELLIDO"]);
printf("</table> ");
}
mysql_free_result($result);
mysql_close($link);
}
if ($seleccion=="nombre"){
}
if ($seleccion=="apellido"){
}
}
?>
$id = 1;
$conn = mysqli_connect('localhost','root','','practicas');
$sql = "SELECT * FROM usuario WHERE id_user = '".$id."'";
$result = mysqli_query($conn,$sql);
echo "
<table border = 1 cellspacing = 1 cellpadding = 1>
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Apellidos</th>
<th>Edad</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>";
<?php
$busqued = isset($_POST['criterio']) ? $_POST['criterio'] : null ;
$seleccion = isset($_POST['selecc']) ? $_POST['selecc'] : null ;
if (strlen($busqued)>1){
if ($seleccion=="cedula"){
$link = @mysqli_connect("localhost", "root", "") or die ('problema conectando porque :' . mysql_error());; //Conectar con el servidor
$basedatos = "Consulta";
mysql_select_db($basedatos, $link);
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>CI</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</th> </tr>";
$result= mysql_query("SELECT CI, NOMBRE, APELLIDO FROM PACIENTES WHERE CI='$busqued'",$link);
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>";
mysql_close($link);
}
if ($seleccion=="nombre"){
}
if ($seleccion=="apellido"){
}
}
?>
$busqued = isset($_POST['criterio']) ? $_POST['criterio'] : null ;
$seleccion = isset($_POST['selecc']) ? $_POST['selecc'] : null ;
if (strlen($busqued)>1){
if ($seleccion=="cedula"){
$link = mysqli_connect("localhost", "root", "", "tubd") or die ('Error de conexion: ' . mysqli_error()); // Cadena de conexión.
$basedatos = "SELECT CI, NOMBRE, APELLIDO 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> </tr>";
$result= mysqli_query($link,$basedatos);
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);
}else if ($seleccion=="nombre"){
// Logica de negocios
}else if ($seleccion=="apellido"){
// Logica de negocios
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<? ob_start (); ?>
<title>RHM</title>
</head>
<script type="text/javascript">
function info(){
pulsado = document.elegir.busqueda;
for (i=0; i<pulsado.length; i++){
valor = pulsado[i].checked;
if (valor==true){
elegido = pulsado[i].value;
}
}
escribe = document.getElementById("selecc");
escribe.value = elegido;
}
</script>
<body>
<form name="elegir" action="#">
<fieldset>
<legend>
<b> Buscar paciente: </b>
</legend>
<p> <b>Criterio de busqueda:</b> <input type="text" name="criterio" id="criterio" onclick="llenar()"/>
<fieldset>
<legend>
<b> Buscar por: </b>
</legend>
<p><input type="radio" name="busqueda" onclick="info()" value="cedula" Checked/> Cedula de identidad
<input type="radio" name="busqueda" onclick="info()" value="nombre"/> Nombre
<input type="radio" name="busqueda" onclick="info()" value="apellido"/> Apellido
<input name="buscar" id="buscar" type="submit" value="Buscar"/>
</p>
</fieldset>
</fieldset>
<input type="text" name="selecc" id="selecc"/>
<p>
<?php
echo "<h3 align='center'>Hasta aqui bien</h3>";
$busqued = isset($_POST['criterio']) ? $_POST['criterio'] : null ;
$seleccion = isset($_POST['selecc']) ? $_POST['selecc'] : null ;
if (strlen($busqued)>1){
if ($seleccion=="cedula"){
$link = mysqli_connect("localhost", "root", "", "Consulta") or die ('Error de conexion: ' . mysqli_error());
// Cadena de conexión.
$result= mysqli_query("SELECT CI, NOMBRE, APELLIDO FROM PACIENTES WHERE CI='$busqued'",$link);
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>CI</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</th> </tr>"; $result= mysqli_query($link,$basedatos);
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);
}
if ($seleccion=="nombre"){
// Logica de negocios
}
if ($seleccion=="apellido"){
// Logica de negocios
}
}
?>
</form>
</body>
<? ob_flush (); ?>
</html>
<html>
<head>
<title>Busqueda Pacientes</title>
</head>
<body>
<form name="frmBuscar" action="#" method="post">
<fieldset>
<legend>
<b>Buscar Paciente</b>
</legend>
<fieldset>
<legend>
<b>Tipo Busqueda</b>
</legend>
<input type="radio" name="rdbBuscar" value="id" checked/>Id
<input type="radio" name="rdbBuscar" value="nombre"/>Nombre
<input type="radio" name="rdbBuscar" value="apellido"/>Apellido</br>
Buscar: <input type="text" name="txtBuscar"/>
<input type="submit" value="Buscar"/>
</fieldset>
</fieldset>
</body>
</form>
</html>
<?php
$seleccion = isset($_POST['rdbBuscar']) ? $_POST['rdbBuscar'] : null;
$busqued = isset($_POST['txtBuscar']) ? $_POST['txtBuscar'] : null;
$link = mysqli_connect("localhost", "root", "", "practicas") or die ('Error de conexion: ' . mysqli_error());
if (strlen($busqued)>1){
if ($seleccion=="id"){
$result= mysqli_query($link,"SELECT ID_USER,NOMBRE,APELLIDOS,EDAD FROM usuario WHERE id_user='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>Id</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</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 ID_USER,NOMBRE,APELLIDOS,EDAD FROM usuario WHERE nombre='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>Id</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</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 ID_USER,NOMBRE,APELLIDOS,EDAD FROM usuario WHERE apellidos='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>Id</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</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);
?>
<?php
$busqued = isset($_POST['criterio']) ? $_POST['criterio'] : null ;
$seleccion = isset($_POST['selecc']) ? $_POST['selecc'] : null ;
if (strlen($busqued)>1){
echo "Todo bien";
}
?>
Si yo omito la linea
if (strlen($busqued)>1){
}
<body></body> == $0
<!DOCTYPE html>
<head>
<title>Busqueda Vehiculos</title>
</head>
<body>
<form name="frmBuscar" action="#" method="post">
<fieldset>
<legend>
<b>Buscar Vehiculos</b>
</legend>
<fieldset>
<legend>
<b>Tipo Busqueda</b>
</legend>
<input type="radio" name="rdbBuscar" value="placa" checked/>Placa
<input type="radio" name="rdbBuscar" value="equipo"/>Equipo
<input type="radio" name="rdbBuscar" value="capacidad"/>Capacidad</br>
Buscar: <input type="text" name="txtBuscar"/>
<input type="submit" value="Buscar"/>
</fieldset>
</fieldset>
</form>
</body>
</html>
<?php
$seleccion = isset($_POST['rdbBuscar']) ? $_POST['rdbBuscar'] : null;
$busqued = isset($_POST['txtBuscar']) ? $_POST['txtBuscar'] : null;
$link = mysqli_connect("1.1.1.1", "usuario", "clave", "data") or die ('Error de conexion: ' . mysqli_error());
if (strlen($busqued)>1){
if ($seleccion=="placa"){
$result= mysqli_query($link,"SELECT placa, numero_equipo, capacidad, modelo FROM vehiculos WHERE placa ='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>Id</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</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=="equipo"){
$result= mysqli_query($link,"SELECT placa, numero_equipo, capacidad, modelo FROM vehiculos WHERE numero_equipo ='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>Id</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</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=="capacidad"){
$result= mysqli_query($link,"SELECT placa, numero_equipo, capacidad, modelo FROM vehiculos WHERE capacidad ='$busqued'");
echo " <table border = 1 cellspacing = 1 cellpadding = 1> <tr> <th>Id</th> <th>Nombre</th> <th>Apellidos</th> <th>Edad</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);
?>