Busqueda en mi web
¿Qué error hay? Me dice que el mysql_fetch_array no es válido. Yo tengo unas tablas programacion, tutoriales, etc y he intentado hacer un pequeño buscador.
<?
$zona_busqueda = $HTTP_GET_VARS["zona_busqueda"];
$string = $HTTP_GET_VARS["string"];
$campos_a_buscar = "(nombre || web || autor || categoria)";
//Conexion con la base
mysql_connect("localhost","","");
mysql_select_db("nobored_es_db");
function busqueda ($tabla, $string_busqueda)
{
if ($tabla!="todas")
{
$sql="SELECT * FROM $tabla WHERE $campos_a_buscar LIKE \'%".$string_busqueda."%\'";
}
else
{
$sql="SELECT * FROM programacion, scripts, descargas, tutoriales, taller WHERE $campos_a_buscar LIKE \'%".$string_busqueda."%\'";
}
$result=mysql_query($sql);
if ($array_resultados=mysql_fetch_array($result))
$resultados=1;
else
$resultados=0;
return $resultados;
}
?>
<html>
<head>
<title> Resultados búsqueda "<? echo "$string" ?>" - no_bored* </title>
<LINK rel="stylesheet" type="text/css" href="estilos.css">
</head>
<body>
<font face="Verdana" size="1">
<div style="font-family: Verdana; color: white; z-index: 5; background-color: #007090; height: 110%; left: 0; position: absolute; top: 0; width: 19%">
<? include("menu_izq.php") ?>
</div>
<div style="z-index: 7; height: 110%; top: 0%; left: 19%; position: absolute; width: 2%; background-color: #ffffff"></div>
<div style="z-index: 10; width: 575; height: 100%; background-color: #ffffff; left: 156; position: absolute; top: 0; font-family: Verdana; font-color: black; font-size: 12pt; font-weight: 500; text-indent: 10pt">
<br><p>
<br><p>
<center><img src="imagenes/banner.gif" border="0" width="449" height="65"></center>
<br><p>
<br><p>
<br><p>
<?
busqueda($zona_busqueda, $string);
echo "<table width=\"100%\">\n";
if($resultado==0)
{
echo "<br><p>\n<center> No hay resultados </center>";
}
else
{
while($array_resultados)
{
echo \'<tr><td colspan="2" class="tablas_resultados"><a href="\'.$array_resultados["id"].\'.php" class="enlaces_der">\'.$array_resultados["nombre"].\'</td></tr>\n<tr><td class="tablas_resultados"><a href="\'.$array_resultados["web"].\'" class="enlaces_der">\'.$array_resultados["web"].\'</a></td><td class="tablas_resultados">\'.$array_resultados["categoria"].\'</td></tr><tr><td colspan="2"><hr color="#002040"></td></tr>\';
}
}
echo "\n</table>";
?>
</div>
</body>
</html>
A ver si me podéis ayudar. Gracias.
<?
$zona_busqueda = $HTTP_GET_VARS["zona_busqueda"];
$string = $HTTP_GET_VARS["string"];
$campos_a_buscar = "(nombre || web || autor || categoria)";
//Conexion con la base
mysql_connect("localhost","","");
mysql_select_db("nobored_es_db");
function busqueda ($tabla, $string_busqueda)
{
if ($tabla!="todas")
{
$sql="SELECT * FROM $tabla WHERE $campos_a_buscar LIKE \'%".$string_busqueda."%\'";
}
else
{
$sql="SELECT * FROM programacion, scripts, descargas, tutoriales, taller WHERE $campos_a_buscar LIKE \'%".$string_busqueda."%\'";
}
$result=mysql_query($sql);
if ($array_resultados=mysql_fetch_array($result))
$resultados=1;
else
$resultados=0;
return $resultados;
}
?>
<html>
<head>
<title> Resultados búsqueda "<? echo "$string" ?>" - no_bored* </title>
<LINK rel="stylesheet" type="text/css" href="estilos.css">
</head>
<body>
<font face="Verdana" size="1">
<div style="font-family: Verdana; color: white; z-index: 5; background-color: #007090; height: 110%; left: 0; position: absolute; top: 0; width: 19%">
<? include("menu_izq.php") ?>
</div>
<div style="z-index: 7; height: 110%; top: 0%; left: 19%; position: absolute; width: 2%; background-color: #ffffff"></div>
<div style="z-index: 10; width: 575; height: 100%; background-color: #ffffff; left: 156; position: absolute; top: 0; font-family: Verdana; font-color: black; font-size: 12pt; font-weight: 500; text-indent: 10pt">
<br><p>
<br><p>
<center><img src="imagenes/banner.gif" border="0" width="449" height="65"></center>
<br><p>
<br><p>
<br><p>
<?
busqueda($zona_busqueda, $string);
echo "<table width=\"100%\">\n";
if($resultado==0)
{
echo "<br><p>\n<center> No hay resultados </center>";
}
else
{
while($array_resultados)
{
echo \'<tr><td colspan="2" class="tablas_resultados"><a href="\'.$array_resultados["id"].\'.php" class="enlaces_der">\'.$array_resultados["nombre"].\'</td></tr>\n<tr><td class="tablas_resultados"><a href="\'.$array_resultados["web"].\'" class="enlaces_der">\'.$array_resultados["web"].\'</a></td><td class="tablas_resultados">\'.$array_resultados["categoria"].\'</td></tr><tr><td colspan="2"><hr color="#002040"></td></tr>\';
}
}
echo "\n</table>";
?>
</div>
</body>
</html>
A ver si me podéis ayudar. Gracias.
