el archivo Buscar.php
Código PHP:
<html>
<body>
<form method="GET" action="buscador.php3">
<strong>Palabra clave:</strong>
<input type="text" name="buscar" size="20"><br><br>
<input type="submit" value="Buscar">
</form>
</body>
</html>
Código PHP:
<html>
<body>
<?php
$buscar = $_GET['buscar'];
if (!isset($buscar)){
echo "Debe especificar una cadena a bucar";
echo "</html></body> \n";
exit;
}
$link = mysql_connect("localhost", "usuario","password");
mysql_select_db("mybasededatos", $link);
$result = mysql_query("SELECT * FROM weblog WHERE contenido LIKE '$buscar' ORDER BY fecha_registro DESC LIMIT 0 , 30", $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["titulo"]."</td> \n";
echo "<td>".$row["descripcion"]."</td> \n";
echo "<td>".$row["metatag"]."</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>
