include('conexion-web.php');
$busqueda = $_GET["b"];
if ($busqueda == "Buscar productos...") { $busqueda = ""; }
if (isset($busqueda)) {
function texto($textohtml) {
$textohtml=str_replace("<","",$textohtml);
$textohtml=str_replace(">","",$textohtml);
$textohtml=str_replace("/","",$textohtml);
$textohtml=str_replace("'","",$textohtml);
$textohtml=str_replace("\"","",$textohtml);
$textohtml=str_replace("*","",$textohtml);
$textohtml=str_replace(",","",$textohtml);
return $textohtml;}
$busqueda = texto($busqueda);
$palabras = sizeof(explode(" ",$busqueda));
if ($palabras == 1) {
$_pagi_sql = "SELECT DISTINCT * FROM productos WHERE
codigo LIKE '%$busqueda%'
OR nombre LIKE '%$busqueda%'
OR descripcion LIKE '%$busqueda%'
AND oculto = 0 ORDER BY nombre";
}
if ($palabras > 1) {
$_pagi_sql = "SELECT * FROM productos WHERE MATCH (codigo,nombre,descripcion) AGAINST ('%$busqueda%' IN BOOLEAN MODE) AND oculto = 0 ORDER BY nombre";
}
?>
RESULTADOS DE SU BÚSQUEDA
} else {
if (!isset($_GET["CatId"]) or (!isset($_GET["SubCatId"]))) {
$_pagi_sql = "SELECT * FROM productos WHERE oculto = 0 ORDER BY nombre ";
echo '
PRODUCTOS
';
} else {
$CatID = $_GET["CatId"];
$SubCat = $_GET["SubCatId"];
if (!is_numeric($CatID)) {
echo '
'; // valido cat
exit;
}
if (!is_numeric($SubCat)) {
echo '
'; // valido subcat
exit;
}
$sql1 = mysql_query("SELECT id,nombre FROM categorias WHERE id = '$CatID' AND oculto = 0") or die ($sql1 .mysql_error() );;
$sql2 = mysql_query("SELECT id,nombre FROM subcategorias WHERE id = '$SubCat' AND oculto = 0") or die ($sql2 .mysql_error() );;
if (mysql_num_rows($sql1) == 0) {
echo '
'; // valido
exit;
}
if (mysql_num_rows($sql2) == 0) {
echo '
'; // valido
exit;
}
$row1 = mysql_fetch_array($sql1);
$row2 = mysql_fetch_array($sql2);
?>
PRODUCTOS » echo strtoupper($row1['nombre']) ?> » echo strtoupper($row2['nombre']) ?>
$_pagi_sql = "SELECT * FROM productos WHERE `rela-subcat` = '$SubCat' AND oculto = 0 ORDER BY nombre ";
}
}
$_pagi_separador = "";
$_pagi_cuantos = 15;
$_pagi_nav_num_enlaces = 10;
include('paginator.inc.php');
if (isset($busqueda) and ($busqueda==false)) {
echo '
No ingresó ningún criterio de búsqueda.
';
} else {
if (isset($busqueda) and (mysql_num_rows($_pagi_result) == 0)) {
echo '
La búsqueda "'.$busqueda.'" no obtuvo resultados.
';
} elseif (mysql_num_rows($_pagi_result) == 0){
echo '
No hay productos en esta sección.
';
} else {
if (isset($busqueda)) {
echo '
La búsqueda "'.$busqueda.'" obtuvo '.mysql_num_rows($_pagi_result).' resultado(s):
';
}
if ($_pagi_totalPags == 1) {$paginador="";} else {$paginador='
'.$_pagi_navegacion.'
';}
}
$_SESSION['URL'] = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
echo $paginador;
$i = 0;
while ($row = mysql_fetch_array($_pagi_result))
{
$i++;
?>
if ($i % 3 == 0) {
echo '
';
}
}
echo '
';
echo $paginador;
}
?>
}
include('PaginaMaestrA.php');