Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/08/2008, 18:29
datauser
 
Fecha de Ingreso: septiembre-2007
Mensajes: 9
Antigüedad: 16 años, 7 meses
Puntos: 0
Ahora ya funciona la clase para paginar registros

Ante todo gracias por contestar GatorV y emiliodeg, la paginación ya funciona con las ligas “anterior”, “siguiente” y “los números de pagina” aunque debo decir que no hice ningún cambio a la clase, no me explico cual haya sido el problema pero de todos modos tendré presente vuestra ayuda para cualquier inconveniente mas adelante gracias una vez mas.

Saludos.

Dejo la clase una vez más por si alguien lo necesite.

Código PHP:
<?php

    
class queryList {

        function 
queryList($sql$link$page$rowsPerPage$pageLimit) {

            
// check the numbers of pages
            
$result        mysql_query($sql);
            
$totalRows    mysql_num_rows($result);
            
$totalPages ceil($totalRows $rowsPerPage);


            
// verify the given values
            
$page $page*1
            
$rowsPerPage $rowsPerPage*1
            
$pageLimit $pageLimit*1
            if(!
is_int($rowsPerPage) || $rowsPerPage 1) { $rowsPerPage 10; }
            if(!
is_int($pageLimit)   || $pageLimit   1) { $pageLimit   10; }
            if(
$page $totalPages) { $page $totalPages; }
            if(!
is_int($page) || $page 1) { $page 1; }


            
// build the starting values
            
if($totalPages $pageLimit ) { $value $pageLimit; } 
                else { 
$value $totalPages; }
            if(
$page $pageLimit) { $i $page $pageLimit$value $pageLimit+$i; }
            
            
$pages "";
            
// section for Previous Record
            
if($page 1){
                
$pages .= '&nbsp;<b>[ <a href='.$link.'&page='.($page-1).'>anterior</a> ] &nbsp;</b>';
            }


            
// build the Pages Browser
            
while (@$i $value){
                @
$i++;
                if (
$i == $page){
                    
$pages .= '<b>['.$i.']</b>&nbsp;';
                } else { 
                    if(
$i <= $totalPages) { 
                        
$pages .= '<a href='.$link.'&page='.$i.'>'.$i.'</a>'
                    }
                }
            }


            
// section for Next Record
            
if($i <= $totalPages){
                if(
$totalPages != $page){
                    
$pages .= '&nbsp;<b>[ <a href='.$link.'&page='.($page+1).'>siguiente</a> ]</b>';
                }
            }


            
// make the return values
            
$this->result $pages;
            
$this->start  = (($page-1) * $rowsPerPage) + 1;
            
$this->total  $totalRows;
            
$this->pages  $totalPages;
            
$this->sql      $sql.' LIMIT '.($page-1)*$rowsPerPage.','.$rowsPerPage;
            
            
$stop "";
            if(
$page==$totalPages) { 
        
$this->stop = ($page-1)*$rowsPerPage+($totalRows-(($page-1)*$rowsPerPage)); 
      } else { 
        
$this->stop $page $rowsPerPage
      }

        } 
// end of query()
        
    
// end of Class


?>