Código PHP:
<html>
<body>
<?php
if (!isset($_POST["T1"];)){
echo "Debe especificar una cadena a buscar";
echo "</html></body> \n";
exit;
}else{
$buscar = $_POST["T1"];
}
$link = mysql_connect("localhost", "usuario","contraseña" ;
mysql_select_db("prueba", $link);
$result = mysql_query("SELECT * FROM agenda WHERE nombre LIKE '%$buscar%' ORDER BY nombre", $link);
$row2=@mysql_num_rows($result);
echo($row2); //me da 3, cuando deberia dar 1
if ( $row2 > 0){
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 "<b><td>".$row["nombre"]."</td></b> \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>
Y asi? El problema es que no aplicaste lo que te comento vevni.
Saludos.