pontxo_manzanilla14 de Junio del 2004
PreguntaHola:
Leyendo vuestro artículo de mysql sobre la búsqueda con índices fulltext y el modo IN BOOLEAN MODE me he animado a hacer un buscador booleano. Pero tengo un problema. Es para buscar en 5 bases de datos... trucos, trucosjuegos, downloads, taller y articulos. La búsqueda la hace perfectamente, pero solo en la de trucos que es la 1º que puse en un if... el código es este:
**************************************************************
<?php require_once('Connections/fullsearch.php'); ?>
<?php
$seccion = $HTTP_GET_VARS['seccion'];
$que = $HTTP_GET_VARS['que'];
if ($seccion='trucos')
{
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsTrucos = "SELECT * FROM trucos WHERE MATCH(descripcion,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsTrucos = mysql_query($query_rsTrucos, $fullsearch) or die(mysql_error());
$row_rsTrucos = mysql_fetch_assoc($rsTrucos);
$totalRows_rsTrucos = mysql_num_rows($rsTrucos);
}
elseif ($seccion='articulos')
{
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsArticulos = "SELECT * FROM articulos WHERE MATCH(titulo,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsArticulos = mysql_query($query_rsArticulos, $fullsearch) or die(mysql_error());
$row_rsArticulos = mysql_fetch_assoc($rsArticulos);
$totalRows_rsArticulos = mysql_num_rows($rsArticulos);
}
elseif ($seccion='downloads') {
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsDownloads = "SELECT * FROM downloads WHERE MATCH(descripgr,descrippq,nombre) AGAINST ('$que IN BOOLEAN MODE')";
$rsDownloads = mysql_query($query_rsDownloads, $fullsearch) or die(mysql_error());
$row_rsDownloads = mysql_fetch_assoc($rsDownloads);
$totalRows_rsDownloads = mysql_num_rows($rsDownloads);
}
elseif ($seccion='taller') {
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsTaller = "SELECT * FROM taller WHERE MATCH(titulo,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsTaller = mysql_query($query_rsTaller, $fullsearch) or die(mysql_error());
$row_rsTaller = mysql_fetch_assoc($rsTaller);
$totalRows_rsTaller = mysql_num_rows($rsTaller);
}
elseif ($seccion='trucosjuegos') {
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsJuegos = "SELECT * FROM trucosjuegos WHERE MATCH(titulo,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsJuegos = mysql_query($query_rsJuegos, $fullsearch) or die(mysql_error());
$row_rsJuegos = mysql_fetch_assoc($rsJuegos);
$totalRows_rsJuegos = mysql_num_rows($rsJuegos);
}
?>
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Estilo1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
</head>
<body>
<?php if ($totalRows_rsTrucos > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en TRUCOS </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsTrucos['Descripcion']; ?></td>
<td class="Estilo1"><?php echo $row_rsTrucos['So']; ?></td>
</tr>
<?php } while ($row_rsTrucos = mysql_fetch_assoc($rsTrucos)); ?>
</table>
<hr>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_rsArticulos > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en ARTÍCULOS </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsArticulos['Titulo']; ?></td>
<td class="Estilo1"><?php echo $row_rsArticulos['DescripPq']; ?></td>
</tr>
<?php } while ($row_rsArticulos = mysql_fetch_assoc($rsArticulos)); ?>
</table>
<hr>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_rsDownloads > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en DOWNLOADS</td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsDownloads['Nombre']; ?></td>
<td class="Estilo1"><?php echo $row_rsDownloads['DescripPq']; ?></td>
</tr>
<?php } while ($row_rsDownloads = mysql_fetch_assoc($rsDownloads)); ?>
</table>
<hr>
<?php if ($totalRows_rsTaller > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en TALLER </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsTaller['Titulo']; ?></td>
<td class="Estilo1"><?php echo $row_rsTaller['DescripPq']; ?></td>
</tr>
<?php } while ($row_rsTaller = mysql_fetch_assoc($rsTaller)); ?>
</table>
<hr>
<?php if ($totalRows_rsJuegos > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en TRUCOS DE JUEGOS </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsJuegos['Titulo']; ?></td>
<td> </td>
</tr>
<?php } while ($row_rsJuegos = mysql_fetch_assoc($rsJuegos)); ?>
</table>
<?php } // Show if recordset not empty ?>
<?php } // Show if recordset not empty ?>
<?php } // Show if recordset not empty ?>
<p class="Estilo1"> </p>
</body>
</html>
<?php
if ($totalRows_rsTrucos > 0) {
mysql_free_result($rsTrucos);}
if ($totalRows_rsArticulos > 0) {
mysql_free_result($rsArticulos); }
if ($totalRows_rsDownloads != 0) {
mysql_free_result($rsDownloads);}
if ($totalRows_rsTaller != 0) {
mysql_free_result($rsTaller);}
if ($totalRows_rsJuegos != 0) {
mysql_free_result($rsJuegos);}
?>
*****************************************************************
Espero que sepáis ayudarme y corregirme... si mismo véis que algo se puede mejorar no os cortéis en decirlo.
Muchas gracias a todos.
Leyendo vuestro artículo de mysql sobre la búsqueda con índices fulltext y el modo IN BOOLEAN MODE me he animado a hacer un buscador booleano. Pero tengo un problema. Es para buscar en 5 bases de datos... trucos, trucosjuegos, downloads, taller y articulos. La búsqueda la hace perfectamente, pero solo en la de trucos que es la 1º que puse en un if... el código es este:
**************************************************************
<?php require_once('Connections/fullsearch.php'); ?>
<?php
$seccion = $HTTP_GET_VARS['seccion'];
$que = $HTTP_GET_VARS['que'];
if ($seccion='trucos')
{
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsTrucos = "SELECT * FROM trucos WHERE MATCH(descripcion,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsTrucos = mysql_query($query_rsTrucos, $fullsearch) or die(mysql_error());
$row_rsTrucos = mysql_fetch_assoc($rsTrucos);
$totalRows_rsTrucos = mysql_num_rows($rsTrucos);
}
elseif ($seccion='articulos')
{
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsArticulos = "SELECT * FROM articulos WHERE MATCH(titulo,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsArticulos = mysql_query($query_rsArticulos, $fullsearch) or die(mysql_error());
$row_rsArticulos = mysql_fetch_assoc($rsArticulos);
$totalRows_rsArticulos = mysql_num_rows($rsArticulos);
}
elseif ($seccion='downloads') {
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsDownloads = "SELECT * FROM downloads WHERE MATCH(descripgr,descrippq,nombre) AGAINST ('$que IN BOOLEAN MODE')";
$rsDownloads = mysql_query($query_rsDownloads, $fullsearch) or die(mysql_error());
$row_rsDownloads = mysql_fetch_assoc($rsDownloads);
$totalRows_rsDownloads = mysql_num_rows($rsDownloads);
}
elseif ($seccion='taller') {
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsTaller = "SELECT * FROM taller WHERE MATCH(titulo,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsTaller = mysql_query($query_rsTaller, $fullsearch) or die(mysql_error());
$row_rsTaller = mysql_fetch_assoc($rsTaller);
$totalRows_rsTaller = mysql_num_rows($rsTaller);
}
elseif ($seccion='trucosjuegos') {
mysql_select_db($database_fullsearch, $fullsearch);
$query_rsJuegos = "SELECT * FROM trucosjuegos WHERE MATCH(titulo,contenido) AGAINST ('$que IN BOOLEAN MODE')";
$rsJuegos = mysql_query($query_rsJuegos, $fullsearch) or die(mysql_error());
$row_rsJuegos = mysql_fetch_assoc($rsJuegos);
$totalRows_rsJuegos = mysql_num_rows($rsJuegos);
}
?>
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Estilo1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
</head>
<body>
<?php if ($totalRows_rsTrucos > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en TRUCOS </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsTrucos['Descripcion']; ?></td>
<td class="Estilo1"><?php echo $row_rsTrucos['So']; ?></td>
</tr>
<?php } while ($row_rsTrucos = mysql_fetch_assoc($rsTrucos)); ?>
</table>
<hr>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_rsArticulos > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en ARTÍCULOS </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsArticulos['Titulo']; ?></td>
<td class="Estilo1"><?php echo $row_rsArticulos['DescripPq']; ?></td>
</tr>
<?php } while ($row_rsArticulos = mysql_fetch_assoc($rsArticulos)); ?>
</table>
<hr>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_rsDownloads > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en DOWNLOADS</td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsDownloads['Nombre']; ?></td>
<td class="Estilo1"><?php echo $row_rsDownloads['DescripPq']; ?></td>
</tr>
<?php } while ($row_rsDownloads = mysql_fetch_assoc($rsDownloads)); ?>
</table>
<hr>
<?php if ($totalRows_rsTaller > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en TALLER </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsTaller['Titulo']; ?></td>
<td class="Estilo1"><?php echo $row_rsTaller['DescripPq']; ?></td>
</tr>
<?php } while ($row_rsTaller = mysql_fetch_assoc($rsTaller)); ?>
</table>
<hr>
<?php if ($totalRows_rsJuegos > 0) { // Show if recordset not empty ?>
<table width="452" border="0" cellspacing="1">
<tr>
<td colspan="2" class="Estilo1">Resultados de la búsqueda de <?php echo $que ?> en TRUCOS DE JUEGOS </td>
</tr>
<?php do { ?>
<tr>
<td class="Estilo1"><?php echo $row_rsJuegos['Titulo']; ?></td>
<td> </td>
</tr>
<?php } while ($row_rsJuegos = mysql_fetch_assoc($rsJuegos)); ?>
</table>
<?php } // Show if recordset not empty ?>
<?php } // Show if recordset not empty ?>
<?php } // Show if recordset not empty ?>
<p class="Estilo1"> </p>
</body>
</html>
<?php
if ($totalRows_rsTrucos > 0) {
mysql_free_result($rsTrucos);}
if ($totalRows_rsArticulos > 0) {
mysql_free_result($rsArticulos); }
if ($totalRows_rsDownloads != 0) {
mysql_free_result($rsDownloads);}
if ($totalRows_rsTaller != 0) {
mysql_free_result($rsTaller);}
if ($totalRows_rsJuegos != 0) {
mysql_free_result($rsJuegos);}
?>
*****************************************************************
Espero que sepáis ayudarme y corregirme... si mismo véis que algo se puede mejorar no os cortéis en decirlo.
Muchas gracias a todos.
