Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/11/2014, 04:38
Avatar de Geghnar
Geghnar
 
Fecha de Ingreso: noviembre-2012
Ubicación: Vigo
Mensajes: 17
Antigüedad: 11 años, 5 meses
Puntos: 2
Respuesta: error en buscador

Hola compañero, he detectado unos cuantos errores; prueba este código:

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>

<?php
    if(!isset($_POST["buscar"])){//NO SE ENVÍA DATO A BUSCAR
?>
    <p>debe especificar una cadena a buscar.</p>
    <p><a href="acceso.html">Volver</a></p>
    
<?php
    exit;    
}

else {//SÍ SE ENVÍA DATO A BUSCAR
	
$link = mysqli_connect("localhost", "root", "", "recetario");
$sql = "SELECT * FROM recetas WHERE nombre LIKE '%".$_POST["buscar"]."%' ORDER BY nombre";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_assoc($result);
$total=mysqli_num_rows($result);

    if($total != 0){//SI HAY RESULTADOS?>
        <table class="miTabla">
<?php        do{
	?>
            <tr>
                <td><?php echo $row["id"];?></td>
                <td><?php echo $row["nombre"];?></td>
                <td><?php echo $row["autor"];?></td>
            	<td><?php echo $row["receta"];?></td>
            	<td><?php echo $row["fecha"];?></td>
            </tr>
        
<?php	}while ($row = mysqli_fetch_assoc($result))?>
		</table>
        <p><a href = acceso.html>Volver</p>
<?php }
	else {//SI NO HAY RESULTADOS?>
		<p>¡No se ha encontrado ningun registro!</p>
		<p><a href = acceso.html>Volver</a></p>
	<?php
	
	}
	
}
	?>



</body>
</html>