Ver Mensaje Individual
  #16 (permalink)  
Antiguo 13/03/2009, 13:30
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
De acuerdo Respuesta: Ayuda - Paginator sin mysql

aca tenes un codigo bien simple para paginar...


Código PHP:
<!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=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<?php 
// para leer el directorio
$ruta "thumbs/"
$filehandle opendir($ruta); 
while (
$file readdir($filehandle)) {
    if (
$file != "." && $file != "..") {
        
$img=$file;
        
$imag=$img.'*'.$imag;
    }
}

closedir($filehandle); 



 
// paginando
$imagenesfile=explode("*"$imag);
$currentpage $_SERVER['PHP_SELF']; // pagina en la que se encuentra
$total=(count($imagenesfile)-1);
$maxRows_Blogdenotas 3;  // cantidad maxima de imagenes a mostrar por pagina
$pageNum_Blogdenotas 0;

if (isset(
$_GET['pag'])) {
  
$pageNum_Blogdenotas intval($_GET['pag']);
}

$startRow_Blogdenotas $pageNum_Blogdenotas $maxRows_Blogdenotas;

if (isset(
$_GET['pag'])) {
  
$pageNum_Blogdenotas intval($_GET['pag']);
}

$startRow_Blogdenotas $pageNum_Blogdenotas $maxRows_Blogdenotas;
$totalRows_Blogdenotas $total;
$totalPages_Blogdenotas ceil($totalRows_Blogdenotas/$maxRows_Blogdenotas)-1;
$images array_slice($imagenesfile$startRow_Blogdenotas$maxRows_Blogdenotas);

// paginando   

?>
Total Imagenes:&nbsp;<?php echo $total;  ?><br /><br />
<table border="0">
                    <tr>
                      <td><?php if ($pageNum_Blogdenotas 0) { // Show if not first page ?>
                            <a href="<?php echo $currentpage?>?pag=0">Primero</a>
                            <?php }else{ // Show if not first page ?>
                            <span class="style1">Primero</span>                            <?php ?>                      </td>
                      <td><?php if ($pageNum_Blogdenotas 0) { // Show if not first page ?>
                            <a href="<?php echo $currentpage?>?pag=<?php echo htmlentities($_GET['pag']-1); ?>">Anterior</a>
                            <?php }else{ // Show if not first page ?>
                            <span class="style1">Anterior</span>                            <?php ?>                      </td>
                      <td><?php if ($pageNum_Blogdenotas $totalPages_Blogdenotas) { // Show if not last page ?>
                            <a href="<?php echo $currentpage?>?pag=<?php echo htmlentities($_GET['pag']+1); ?>">Siguiente</a>
                            <?php }else{ // Show if not last page ?>
                            <span class="style1">Siguiente</span>                            <?php ?>                      </td>
                      <td><?php if ($pageNum_Blogdenotas $totalPages_Blogdenotas) { // Show if not last page ?>
                            <a href="<?php echo $currentpage?>?pag=<?php echo $totalPages_Blogdenotas ?>">Ultimo</a>
                            <?php }else{ // Show if not last page ?>
                            <span class="style1">Ultimo</span>                            <?php ?>                      </td>
                    </tr>
                  </table>
<div>                  Mostrando <?php echo ($startRow_Blogdenotas 1?> a <?php echo min($startRow_Blogdenotas $maxRows_Blogdenotas$totalRows_Blogdenotas?> de <?php echo $totalRows_Blogdenotas ?></div><br /><br />

<?php
foreach ($images as $image) { 
$tamayo=getimagesize($ruta $image);
//echo $image;
echo "<img src='$ruta$image' width='100' />";
//echo "<img src='$ruta$image' $tamayo[3] />";
}
?>
</body>
</html>
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)

Última edición por farra; 13/03/2009 a las 14:42 Razón: falto parte del codigo...