Foros del Web » Programando para Internet » PHP »

Pagina PHP al estilo DreamWeaver

Estas en el tema de Pagina PHP al estilo DreamWeaver en el foro de PHP en Foros del Web. Hola gente... Bueno aqui les traigo un páginado muy sencillo.... reemplazar el $lnk con su variable de enlace a su base de datos $PagRef = ...
  #1 (permalink)  
Antiguo 04/07/2008, 09:47
 
Fecha de Ingreso: agosto-2006
Ubicación: Girardot
Mensajes: 27
Antigüedad: 17 años, 8 meses
Puntos: 2
De acuerdo Pagina PHP al estilo DreamWeaver

Hola gente...

Bueno aqui les traigo un páginado muy sencillo.... reemplazar el $lnk con su variable de enlace a su base de datos

$PagRef = $_SERVER['PHP_SELF']; /* Página de referencia */
$RegFin=10; /* Registroa a mostrar */
/* Capturamos nuestras páginas */
if(isset($_GET['pag'])){
$RegIni=($_GET['pag']-1)*$RegFin;
$PagAct=$_GET['pag'];
}else{
$RegIni=0; /* Registro inicial */
$PagAct=1; /* Número de página actual */
}
/* SQL de nuestra consulta, Reemplazar por obvias razones */
$sql_sub="SELECT * FROM tbl_subgrpart ORDER BY detsubgrp";
$lmt_sub=sprintf("%s LIMIT %d,%d",$sql_sub,$RegIni,$RegFin);
$qry_sub=mysql_query($lmt_sub, $lnk) or die(mysql_error());
$reg_sub=mysql_fetch_assoc($qry_sub);
$tot_sub=mysql_num_rows($qry_sub);
$qry_reg=mysql_query($sql_sub, $lnk) or die(mysql_error());
$tot_reg=mysql_num_rows($qry_reg);
$PagAnt=$PagAct-1;
$PagSig=$PagAct+1;
$PagUlt=$tot_reg/$RegFin;
$Res = $tot_reg%$RegFin;
if($Res>0) $PagUlt=floor($PagUlt)+1


Ahora viene el chiste de Primero, Anterior, Siguiente, Último
Nota: Las imagenes que hago referencia las saque de phpmyadmin de la carpeta themes...

<!-- Primero -->
<?php if($RegIni>0){ ?>
<a href="<?php echo $PagRef."?pag=1" ?>">
<img src="img/b_firstpage.png" width="16" height="16" border="0" /></a>
<?php }else{ ?>
<img src="img/bd_firstpage.png" width="16" height="16" border="0" />
<?php } ?>
<!-- Anterior -->
<?php if($PagAct>1){ ?>
<a href="<?php echo $PagRef."?pag=".$PagAnt ?>">
<img src="mg/b_prevpage.png" width="16" height="16" border="0" /></a>
<?php }else{?>
<img src="img/bd_prevpage.png" width="16" height="16" border="0" />
<?php }?>
<!-- Siguiente -->
<?php if($PagAct<$PagUlt){ ?>
<a href="<?php echo $PagRef."?pag=".$PagSig ?>">
<img src="img/b_nextpage.png" width="16" height="16" border="0" /></a>
<?php }else{?>
<img src="img/bd_nextpage.png" width="16" height="16" border="0" />
<?php }?>
<!-- Último -->
<?php if($PagSig<=$PagUlt){ ?>
<a href="<?php echo $PagRef."?pag=".$PagUlt ?>">
<img src="img/b_lastpage.png" width="16" height="16" border="0" /></a>
<?php }else{ ?>
<img src="img/bd_lastpage.png" width="16" height="16" border="0" /></a>
<?php }?>

Bueno y aún no acabamos... Ahora haremos un conteo de nuestros registros por pantalla y de las páginas que tengamos.

Página <?php echo $PagAct ?> de <?php echo $PagUlt ?><br>
Registros por página del <?php echo ($RegIni+1); ?> al <?php echo min($RegIni+$RegFin, $tot_reg); ?> de <?php echo $tot_reg; ?>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:19.