Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/06/2010, 16:24
pilucho
 
Fecha de Ingreso: noviembre-2004
Ubicación: NULL
Mensajes: 652
Antigüedad: 19 años, 5 meses
Puntos: 6
Ayuda Paginacion php

Hola Alguien Puede ayudarme con este codigo, resulta que la paginacion funciona bien pero el problema es que me muestra todo los numeros de paginas.

Actualmente me sale asi:
Ejemplo:
1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28-29-30


Y la idea es asi:
Ejemplo:
1-2-3-4-5.. 10.. 20.. 30.. 40

Alguien puede ayudarme con este codigo porfavor.



Código PHP:
<?
// Requiere ADODB
class pager
{
    var 
$row;
    var 
$pages;
    var 
$currentpage;
    var 
$limit//limit
    
var $numrows;
    var 
$first;
    var 
$last;
    function 
pager($conn$row$limit=10$getNumRowsSQL)
    {
        if (!isset(
$row)) $row 0;
        
$this->row $row;
        
$this->limit $limit;
        
$this->numrows $conn->GetOne($getNumRowsSQL);
        if ((
$this->numrows $this->limit) == 0$this->pages = ($this->numrows/$this->limit);
        else 
$this->pages intval($this->numrows/$this->limit) + 1;
        
$this->currentpage = ($this->row/$this->limit) + 1;
        
$this->first = ($this->row 1);
        if ((
$this->row $this->limit) >= $this->numrows$this->last $this->numrows; else $this->last = ($this->row $this->limit);
    }
    function 
getrecords($conn$sql$array=false)
    {
        
$recordSet = &$conn->SelectLimit($sql,$this->limit,$this->row);
        if (!
$array) return $recordSet;
        return 
$recordSet->getArray(); 
    }
    function 
showpagernav($backtext 'Atras'$nexttext 'Siguiente'$otherargs='')
    {
        if (
$this->pages 1)
        {
            echo 
'<table>';
            
// Enlace Atras
            
echo '<td width="30">';
            if (
$this->row != 0
            {
                
$backPage $this->row $this->limit;  
                echo 
"<a href=\"".$_SERVER['PHP_SELF']."?row=".$backPage.$otherargs."\">$backtext</a>\n";
            }
            else echo 
'&nbsp;';
            echo 
'</td>';
            
// Enlace Paginas
            
echo '<td>';
            for (
$i=1$i <= $this->pages$i++) 
            {  
                
$ppage $this->limit*($i 1);
                if (
$ppage == $this->row)
                {
                    echo 
"<b>$i</b>&nbsp;&nbsp; \n";
                }
                else 
                {
                    echo 
"<a href=\"".$_SERVER['PHP_SELF']."?row=".$ppage.$otherargs."\">$i</a>&nbsp;&nbsp; \n";
                }
            }
            echo 
'</td>';
            
// Enlace Siguiente
            
if ($this->currentpage $this->pages
            { 
                
$nextPage $this->row $this->limit;
                echo 
"<td><a href=\"".$_SERVER['PHP_SELF']."?row=".$nextPage.$otherargs."\">$nexttext</a></td>\n";
            }
            echo 
'</table>';
        }
        else echo 
"&nbsp;";
    }    
}
?>