Acá te dejo un pequeño buscador... dividido en dos archivos:
index.php
Código PHP:
<form method="post" action="buscador.php" form name="formulario" >
<table width="100%" cellpadding="0" cellspacing="3" border="0">
<tr>
<td><div align="center"><b>Buscar:</b></div></td>
</tr>
<tr>
<td><input type="text" name="palabras" size="20" maxlength="65" class="form"></td>
</tr>
<tr>
<td><input type="submit" name="buscar" value="Buscar" class="form "></td>
</tr>
</table>
</form>
buscador.php
Código PHP:
<?
if($buscar) {
$dbhost = "localhost" ;
$dbuser = "usuario" ;
$dbpass = "pass" ;
$db = "nombre bd" ;
$conectar = mysql_connect($dbhost,$dbuser,$dbpass) ; mysql_select_db($db,$conectar) ;
$resp = mysql_query("select * from TUTABLA where CAMPO like '%$palabras%'") ;
if(mysql_num_rows($resp) == 0) {
echo "No se encontraron resultados en la búsqueda." ;
}
else {
while($datos = mysql_fetch_array($resp)) {
echo "
<table width='100%' border='0' cellpadding='5' cellspacing='0'>
<tr>
<td width='75%' height='15'><div>
<a href=noticias/ver.php?i=$datos[id]>$datos[titulo]</a></div></td>
</tr>
</table><br>" ;
}
}
}
?>