Hola a todos.
Se me ha presentado un problema y realmente no se como hacerlo. Tengo que hacer un buscador que me busque en en cinco campos distintos de la misma tabla.
El problema que se me presenta es que no se como mostrar los resultados.
Les envio el codigo para que vean y me comenten algo si le ven la solución.
Un saludo
Código PHP:
<? include("../includes/config.php"); ?>
<?php
$palabra = $HTTP_POST_VARS['palabra'];
if (isset($HTTP_POST_VARS['enviar'])) {
$resp = mysql_query("select id, ficheroarticulo, articulo1texto, articulo2texto, articulo3texto, articulo4texto, articulo5texto from revista where articulo1texto LIKE '%".$HTTP_POST_VARS[palabra]."%' or articulo2texto LIKE '%".$HTTP_POST_VARS[palabra]."%' or articulo3texto LIKE '%".$HTTP_POST_VARS[palabra]."%' or articulo4texto LIKE '%".$HTTP_POST_VARS[palabra]."%' or articulo5texto LIKE '%".$HTTP_POST_VARS[palabra]."%'") or die (mysql_error());
if(mysql_num_rows($resp) == "0") {
echo "No hay resultados";
} else {
?>
<link href="../style/miestilo.css" rel="stylesheet" type="text/css">
<table width="100%" border="0" cellpadding="0" cellspacing="3">
<tr>
<td class="botonform"><div align="center" class="negrita">La Revista </div></td>
</tr>
</table>
<form action="buscador.php" method="post">
<table width="100%" height="20" border="0" align="center" cellpadding="0" cellspacing="3">
<tr>
<td class="footer" >
<div align="right"> Buscador de artículos de la Revista
<input name="palabra" type="text" class="input_text" size="60">
<input name="enviar" type="submit" class="inputform" value="Buscar">
</div></td>
</tr>
</table>
</form>
<table width="100%" height="75%" border="0" cellpadding="1" cellspacing="5" class="marco">
<tr class="fonsblau_claret">
<td valign="top"><? echo "Resultados de la busqueda:<br>"; ?><br><br>
<table width="100%" border="0" cellspacing="3" cellpadding="0" class="marco">
<?
while ($buscador=mysql_fetch_object($resp)){
if ($palabra == $buscador['articulo1texto']) { ?>
<tr>
<td valign="top"><div align="justify"><a href="../larevista/<?php echo $buscador->ficheroarticulo;?>"><? echo $buscador->articulo1texto;?></a> </div></td>
</tr>
<? } elseif ($palabra == $buscador['articulo2texto']) {?>
<tr>
<td valign="top"><div align="justify"><a href="ver_detalle.php"><? echo $buscador->articulo2texto;?></a> </div></td>
</tr>
<? } elseif ($palabra == $buscador['articulo3texto']) {?>
<tr>
<td valign="top"><div align="justify"><a href="ver_detalle.php"><? echo $buscador->articulo3texto;?></a> </div></td>
</tr>
<? } elseif ($palabra == $buscador['articulo4texto']) {?>
<tr>
<td valign="top"><div align="justify"><a href="ver_detalle.php"><? echo $buscador->articulo4texto;?></a> </div></td>
</tr>
<? } elseif ($palabra == $buscador['articulo5texto']) {?>
<tr>
<td valign="top"><div align="justify"><a href="ver_detalle.php"><? echo $buscador->articulo5texto;?></a> </div></td>
</tr><? } }?>
</table></td>
</tr>
</table>
<?
}
}
?>