Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/04/2004, 11:33
wjlopez
 
Fecha de Ingreso: marzo-2004
Mensajes: 109
Antigüedad: 20 años, 1 mes
Puntos: 0
Consulta de registros

hola de nuevo.....
espero no aburrir... pero deverdad que me parece facinante esto de la programación en PHP y ahora me meti en otra duda....

quiero hacer consultas de registros de mi base da datos en MySQL a partir de este formulario

<html>
<body>
<form method="POST" action="http://localhost/consulta/buscador.php3">
<strong>Palabra clave:</strong> <input type="text" name="T1" size="20"><br><br>
<input type="submit" value="Buscar" name="buscar">
</form>
</body>
</html>

luego quiero que me regrese un resultado con esta pagina PHP

<html>
<body>

<?php
if (!isset($buscar)){
echo "Debe especificar una cadena a bucar";
echo "</html></body> \n";
exit;
}
$link = mysql_connect("localhost", "");
mysql_select_db("mydb", $link);
$result = mysql_query("SELECT * FROM agenda WHERE nombre LIKE '%$buscar%' ORDER BY nombre", $link);
if ($row = mysql_fetch_array($result)){
echo "<table border = '1'> \n";
//Mostramos los nombres de las tablas
echo "<tr> \n";
while ($field = mysql_fetch_field($result)){
echo "<td>$field->name</td> \n";
}
echo "</tr> \n";
do {
echo "<tr> \n";
echo "<td>".$row["id"]."</td> \n";
echo "<td>".$row["nombre"]."</td> \n";
echo "<td>".$row["direccion"]."</td> \n";
echo "<td>".$row["telefono"]."</td> \n";
echo "<td><a href='mailto:".$row["email"]."'>".$row["email"]."</a></td> \n";
echo "</tr> \n";
} while ($row = mysql_fetch_array($result));
echo "</table> \n";
} else {
echo "¡ No se ha encontrado ningún registro !";
}
?>

</body>
</html>

pero apezar que existen registros en mi tabla agenda me aparece un mensajeq ue dice ... no hay datos relacionados-- que puedo hacer....