//inicializo el criterio y recibo cualquier cadena que se desee buscar
$criterio = "";
$txt_criterio = "";
if (($_GET["tipo"]!="") and ($_GET["tipo"]!="Todo")) {
$txt_criterio = $_GET["tipo"];
if ($restipo=="Ba") {
$txt_criterio = "Ba%adores y Bikinis";
}
$criterio = " where etiquetas = '" . $txt_criterio . "'";
} else {
$txt_criterio= "xxx";
$criterio = " where tipo not like '%" . $txt_criterio . "%'";
}
if (($_GET["genero"]!="") and ($_GET["genero"]!="Todos")) {
$txt_criterio = $_GET["genero"];
if ($rest=="Ni") {
$txt_criterio = "Ni%".$rest1;
}
$criterio = $criterio. " and genero like '%" . $txt_criterio . "%'";
} else {
$txt_criterio= "xxx";
$criterio = $criterio ." and genero not like '%" . $txt_criterio . "%'";
}
if (($_GET["marca"]!="") and ($_GET["marca"]!="Todas")) {
$txt_criterio = $_GET["marca"];
$criterio = $criterio. " and tienda like '%" . $txt_criterio . "%'";
} else {
$txt_criterio= "xxx";
$criterio = $criterio ." and tienda not like '%" . $txt_criterio . "%'";
}
if (($_GET["desde"]!="") and ($_GET["desde"]!="Todas")) {
$txt_criterio = $_GET["desde"];
$criterio = $criterio. " and precio > '" . $txt_criterio . "'";
}
if (($_GET["hasta"]!="") and ($_GET["hasta"]!="Todas")) {
$txt_criterio = $_GET["hasta"];
$criterio = $criterio. " and precio < '" . $txt_criterio . "'";
}
if ($_GET["frase"]!="") {
$txt_criterio = $_GET["frase"];
$criterio = $criterio. " and ( nombre like '%" . $txt_criterio . "%' or descripcioncorta like '%". $txt_criterio . "%' )" ;
}
if ($_GET["moda"]!="") {
$txt_criterio = $_GET["moda"];
$criterio = " where nombre like '%" . $txt_criterio . "%' or descripcioncorta like '%" . $txt_criterio . "%'";
}
$sql="SELECT SQL_CACHE * FROM tabla2 " . $criterio ;
//echo $sql;
$res=mysql_query($sql);
$numeroRegistros=mysql_num_rows($res);
if($numeroRegistros<=0)
{
echo "
";
echo "No se encontraron resultados";
echo "
";
}else{
//////////elementos para el orden
if(!isset($orden))
{
$orden="numero";
}
//////////fin elementos de orden
//////////calculo de elementos necesarios para paginacion
//tamaño de la pagina
$tamPag=10;
//pagina actual si no esta definida y limites
if(!isset($_GET["pagina"]))
{
$pagina=1;
$inicio=1;
$final=$tamPag;
}else{
$pagina = $_GET["pagina"];
}
//calculo del limite inferior
$limitInf=($pagina-1)*$tamPag;
//calculo del numero de paginas
$numPags=ceil($numeroRegistros/$tamPag);
if(!isset($pagina))
{
$pagina=1;
$inicio=1;
$final=$tamPag;
}else{
$seccionActual=intval(($pagina-1)/$tamPag);
$inicio=($seccionActual*$tamPag)+1;
if($pagina<$numPags)
{
$final=$inicio+$tamPag-1;
}else{
$final=$numPags;
}
if ($final>$numPags){
$final=$numPags;
}
}
//////////fin de dicho calculo
//////////creacion de la consulta con limites
$sql="SELECT * FROM tabla2 ".$criterio." ORDER BY precio ASC, nombre asc LIMIT ".$limitInf.",".$tamPag;
$res=mysql_query($sql);
//////////fin consulta con limites
echo "
";
echo "Encontrados ".$numeroRegistros." resultados ";
echo "Ordenados por ".$orden."";
if(isset($txt_criterio)){
echo " Valor filtro: ".$filtro."";
}
echo "