Ver Mensaje Individual
  #4 (permalink)  
Antiguo 21/01/2010, 15:12
albertrc
 
Fecha de Ingreso: febrero-2009
Mensajes: 443
Antigüedad: 15 años, 2 meses
Puntos: 1
Respuesta: ayuda con paginacion

aun me da error pero he hecho que la url se ajuste a la salida que seria buena y tenia un error en la consulta pero de momento tampoco funciona
http://localhost/php/paginacion.php?id_categoria=00

http://localhost/php/paginacio.php?i...goria=00?pag=1
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/html/php/paginacio/paginacio.php on line 28




Código PHP:
//maximo por pagina 
$limit 4
 
// pagina pedida 
$pag = (int) $_GET["pag"]; 
if (
$pag 1

   
$pag 1

$offset = ($pag-1) * $limit
 
 
$sql "SELECT SQL_CALC_FOUND_ROWS nombre_categoria,nombre_producto,ruta_foto_grande,ruta_foto_pequena,descripcion_producto FROM producto,foto,categoria where id_foto=producto_id_foto and id_categoria=producto_id_categoria  and id_categoria=$_GET[id_categoria]  group by nombre_producte   LIMIT $offset, $limit"
$sqlTotal "SELECT FOUND_ROWS() as total"
 
$rs mysql_query($sql); 
$rsTotal mysql_query($sqlTotal); 
 
$rowTotal mysql_fetch_assoc($rsTotal); 
// Total de registros sin limit 
$total $rowTotal["total"]; 
 
$nombre_categoria=0;
         while (
$row mysql_fetch_assoc($rs)) 
         { 
                        echo 
"<div class='producto'>";
        if(
$nombre_categoria==0){
            echo    
"  <div class='categoria'><h1>".ucfirst("{$row['nombre_categoria']}")."</h1></div>";
        }
            echo 
"<div class='nombre'><h2>{$row['nombre_producto']}</h2></div>
                 <div class='imagen'>
                     <a href=' {$row['ruta_foto_grande']}' /><img src=' {$row['ruta_foto_pequena']} '/></a>
                     <div class='ampliar'>
                         <p><a href=' {$row['ruta_foto_grande']}' />ampliar</a></p></div>
                 </div>
                 <div class='descripcion'><p>{$row['descripcion_producto']}</p></div></br></br></br><hr></div></br>    "
;
      
$nombre_categoria++;
 }
     
      

         
$totalPag ceil($total/$limit); 
         
$links = array(); 
         for( 
$i=1$i<=$totalPag $i++) 
         { 
            
$links[] = "<a href=\"?id_categoria=$_GET[id_categoria]?pag=$i\">$i</a>";  
         } 
         echo 
implode(" - "$links); 
      
?>