Adaptá este código a tu necesidad amigo:
Código PHP:
<div align="center"><form action="index.php?m=buscar" method="post">
<fieldset>
Búsqueda de texto<br>
<input name="palabra">
<input type="submit" value=" " name="buscador" class="busqboton" />
</fieldset>
</form></div>
<?
if ($_POST['buscador'])
{
// Tomamos el valor ingresado
$buscar = $_POST['palabra'];
// Si está vacío, lo informamos, sino realizamos la búsqueda
if(empty($buscar))
{
echo "No se ha ingresado una cadena a buscar";
}else{
require 'm/delivery/admin/conexion.php';
//$sql = "SELECT noticias.titulo FROM noticias WHERE titulo like '%$buscar%' ORDER BY id DESC";
//$sql = "SELECT copete, idNoticia FROM noticias WHERE noticias.copete like '%$buscar%' ORDER BY idNoticia DESC";
$query = "SELECT * FROM noticias WHERE noticias.copete like '%$buscar%' ORDER BY idNoticia DESC";
//$result = mysql_query($sql, $dbConn);
$arrNoticias = array();
$resultado = mysql_query ($query, $dbConn);
while ( $row = mysql_fetch_assoc ($resultado))
{
array_push( $arrNoticias,$row );
$total = $arrNoticias;
}
// Tomamos el total de los resultados
//$total = mysql_num_rows($result);
// Imprimimos los resultados
//if ($row = mysql_fetch_array($result)){
if ($total > 0){
echo "<p>Resultados para: <b>$buscar</b></p>";
do {
//ACA SE MOSTRARAN LOS RESULTADOS ENCONTRADOS
?>
<? foreach ( $arrNoticias as $noticias ) { ?>
<div align="center">
<table width="500" border="0" cellspacing="0" cellpadding="0" class="tbl1">
<tr>
<td width="120" height="85" rowspan="2" class="tbl1"><img src="img/articulos/<? echo $noticias['titulo']; ?>" width="120" height="85"></td>
<td width="198" height="18" class="art2"><? echo $noticias['copete']; ?></td>
<td width="182">
<script>
function abrirPopUp(href, target, flags) {
if (flags=='') flags='chrome,centerscreen,dependent=YES,dialog=no,toolbar=0,resizable=YES,scrollbars=YES,location=0,status=0,menubar=0,toolbar=0,width=600px,height=500px,modal=yes,left = NaN,top = NaN';
if (target=='')
target='_blank';
window.open(href,target,flags);
}
</script>
<?PHP
if(!empty($noticias['tipo']) ) {
?>
<a href="#" onClick="abrirPopUp('articulos.php?blog=<? echo $noticias['tipo']; ?>&idNoticia=<? echo $noticias['idNoticia']; ?>','','')"><img src="img/detalle.png" width="41" height="27" border="0" /></a>
<?PHP
}
?>
<?PHP
if(!empty($noticias['link']) ) {
?>
<a href="http://<? echo $noticias['link']; ?>"><img src="img/WWW.png" width="57" height="27" border="0" /></a>
<?PHP
}
?>
<?PHP //<a href="index.php?m=maps"><img src="img/ubicacion.png" width="65" height="27" border="0" /></a> ?>
</td>
</tr>
<tr>
<td height="43" colspan="2" class="art1">
<? echo $noticias['cuerpo']; ?> <br />
<? echo $noticias['domicilio']; ?> <br />
<? echo $noticias['horario']; ?> <br />
(0291) - <? echo $noticias['telefono']; ?>
</td>
</tr>
</table>
</div>
<br />
<?PHP } ?>
<?
} while ($row = mysql_fetch_array($resultado));
//echo "<p>Resultados: $total</p>";
} else {
// En caso de no encontrar resultados
echo "No se encontraron resultados para: <b>$buscar</b>";
}
}
}
?>