saludos mortiprogramador, mira esto es lo que tengo:
Código PHP:
$RegistrosAMostrar=10;
if(isset($_GET['pag'])){
$RegistrosAEmpezar=($_GET['pag']-1)*$RegistrosAMostrar;
$PagAct=$_GET['pag'];
}else{
$RegistrosAEmpezar=0;
$PagAct=1;
}
$datos = mysql_query("SELECT * FROM categorias_padre WHERE link = '$url1'", $conexion) or die(mysql_error());
$fetch = mysql_fetch_array($datos);
if(!empty($uso) and !empty($primero)) {
if ($primero == "baratos") {
if ($uso == "todos") {
$consulta = "SELECT * FROM $url1 WHERE precio IN (SELECT MIN(precio) minimo FROM $url1 group by id_t ORDER BY minimo ASC) group by id_t ORDER BY precio ASC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } else {
$consulta = "SELECT * FROM $url1 WHERE precio IN (SELECT MIN(precio) minimo FROM $url1 group by id_t ORDER BY minimo ASC) AND condicion='$uso' group by id_t ORDER BY precio ASC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } }
if ($primero == "caros") {
if ($uso == "todos") {
$consulta = "SELECT * FROM $url1 WHERE precio IN (SELECT MAX(precio) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY precio DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } else {
$consulta = "SELECT * FROM $url1 WHERE precio IN (SELECT MAX(precio) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY precio DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } }
if ($primero == "comentados") {
if ($uso == "todos") {
$consulta = "SELECT * FROM $url1 WHERE comentarios IN (SELECT MAX(comentarios) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY comentarios DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } else {
$consulta = "SELECT * FROM $url1 WHERE comentarios IN (SELECT MAX(comentarios) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY comentarios DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } }
if ($primero == "valorados") {
if ($uso == "todos") {
$consulta = "SELECT * FROM $url1 WHERE valoraciones IN (SELECT MAX(valoraciones) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY valoraciones DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } else {
$consulta = "SELECT * FROM $url1 WHERE valoraciones IN (SELECT MAX(valoraciones) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY valoraciones DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } }
if ($primero == "novedades") {
if ($uso == "todos") {
$consulta = "SELECT * FROM $url1 WHERE fecha IN (SELECT MAX(fecha) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY fecha DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } else {
$consulta = "SELECT * FROM $url1 WHERE fecha IN (SELECT MAX(fecha) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY fecha DESC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } }
}
else {
if(!empty($uso)) {
if ($uso == "todos") {
$consulta = "SELECT count(*), id_t,nombre,img,precio,id_tienda FROM $url1 group by id_t, precio ASC LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } else {
$consulta = "SELECT count(*), id_t,nombre,img,precio,id_tienda FROM $url1 where condicion='$uso' group by id_t LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; }
} else { $consulta = "SELECT count(*), id_t,nombre,img,precio,id_tienda FROM $url1 group by id_t LIMIT $RegistrosAEmpezar, $RegistrosAMostrar"; } }
$resultado = mysql_query($consulta, $conexion) or die(mysql_error());
if(!empty($uso) and !empty($primero)) {
if ($primero == "baratos") {
if ($uso == "todos") {
$consulta2 = "SELECT * FROM $url1 WHERE precio IN (SELECT MIN(precio) minimo FROM $url1 group by id_t ORDER BY minimo ASC) group by id_t ORDER BY precio ASC"; } else {
$consulta2 = "SELECT * FROM $url1 WHERE precio IN (SELECT MIN(precio) minimo FROM $url1 group by id_t ORDER BY minimo ASC) AND condicion='$uso' group by id_t ORDER BY precio ASC"; } }
if ($primero == "caros") {
if ($uso == "todos") {
$consulta2 = "SELECT * FROM $url1 WHERE precio IN (SELECT MAX(precio) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY precio DESC "; } else {
$consulta2 = "SELECT * FROM $url1 WHERE precio IN (SELECT MAX(precio) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY precio DESC"; } }
if ($primero == "comentados") {
if ($uso == "todos") {
$consulta2 = "SELECT * FROM $url1 WHERE comentarios IN (SELECT MAX(comentarios) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY comentarios DESC"; } else {
$consulta2 = "SELECT * FROM $url1 WHERE comentarios IN (SELECT MAX(comentarios) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY comentarios DESC"; } }
if ($primero == "valorados") {
if ($uso == "todos") {
$consulta2 = "SELECT * FROM $url1 WHERE valoraciones IN (SELECT MAX(valoraciones) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY valoraciones DESC"; } else {
$consulta2 = "SELECT * FROM $url1 WHERE valoraciones IN (SELECT MAX(valoraciones) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY valoraciones DESC"; } }
if ($primero == "novedades") {
if ($uso == "todos") {
$consulta2 = "SELECT * FROM $url1 WHERE fecha IN (SELECT MAX(fecha) maximo FROM $url1 group by id_t ORDER BY maximo DESC) group by id_t ORDER BY fecha DESC"; } else {
$consulta2 = "SELECT * FROM $url1 WHERE fecha IN (SELECT MAX(fecha) maximo FROM $url1 group by id_t ORDER BY maximo DESC) AND condicion='$uso' group by id_t ORDER BY fecha DESC"; } }
}
else { $consulta2 = "SELECT count(*), id_t,nombre,img,MIN(precio),id_tienda FROM $url1 group by id_t"; }
$resultado2 = mysql_query($consulta2, $conexion) or die(mysql_error());
$NroRegistros=mysql_num_rows($resultado2);
?>
<? while($fetch = mysql_fetch_assoc($resultado)){
La consulta es la misma solo que cambio MIN(precio) por MAX(precio) "minimo" por "maximo" y el order...