Ver Mensaje Individual
  #4 (permalink)  
Antiguo 27/04/2010, 17:41
cuco43
 
Fecha de Ingreso: noviembre-2008
Mensajes: 36
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: paginador de registros

hola

Ell3er te muestro el código completo:
Código PHP:
<?php
include ("conexion.php");
$rst_productos=mysql_query("SELECT * FROM lider ORDER BY nombres",$conexion);
$num_registros=mysql_num_rows($rst_productos);
if (
$num_registros=0)
{echo 
"no se ha encontrado nada que mostrar";
    
mysql_close($conexion);
    exit();}

    
$registros=4;
    
$pagina=$_GET["num"];
        
        if(
is_numeric($pagina))
        
$inicio=(($pagina-1)*$registros);
else
$inicio=0;
    
$rst_productos=mysql_query("SELECT * FROM lider ORDER BY nombres LIMIT $inicio,$registros;",$conexion);
$paginas=ceil($num_registros/$registros);
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style2 {font-weight: bold}
-->
</style>
</head>

<body>
<form action="consultaprueba.php" method="post" name="form1" id="form1">
  <div align="center"><strong>  LISTADO DE PRODUCTOS  </strong>
  </div>
</form>
<table width="800" border="1" align="center" cellpadding="5" cellspacing="2">
  <tr>
    <td style=with: 52px class="style2"><strong>Clave Sede</strong></td>
    <td style=with: 222px class="style2"><div align="center">Clave Lider</div></td>
    <td style=with: 188px class="style2"><div class="style1" aling="center">
      <div align="center"><strong>Nombre Lider</strong></div>
    </div>        </td>
    <td style=with: 92px class="style2"><div align="center"><strong>Modificar</strong></div></td> 
    <td class="style2"><div align="center"><strong>Eliminar</strong></div></td>
  </tr>
  <?php
  
while ($fila=mysql_fetch_array($rst_productos))
  {
  
?>
  <tr>
    <td style=with: 52px class="style2"><?php echo $fila[1]?></td>
    <td style=with: 222px class="style2"><?php echo $fila[2]?></td>
    <td style=with: 188px class="style2"><div aling="center"><?php echo $fila["nombres"]?></div>        </td>
    <td style=with: 92px class="style2">&nbsp;</td> 
    <td class="style2">&nbsp;</td>
  </tr>
   <?php
  
}
  
?>
  //scrip que hace la paginacion
</table>
<form id="form2" name="form2" method="post" action="">
  <div align="center">
    <?php 
    
for($cont=1;$cont<=$pagina;$cont++);
    {
        if (
$cont==$pagina)
        echo 
$cont ." ";
        else
        echo 
"<a href='lider.php?num=".$cont."'>$cont</a> ";
//        echo $cont."<a href='lider.php?num=".$cont."'>$cont</a> ";
    
}
?>
  </div>
</form>
<p>&nbsp;</p>
</body>
</html>
Experimenta, estoy chacando tus sugerencias.

Gracias.