InicioCiencia EducacionPaginar Archivos Sin Mysql

Paginar Archivos Sin Mysql

Ciencia Educacion9/27/2011
<?php 
// para leer el directorio
$ruta "archivos/"
$filehandle opendir($ruta); 
while (
$file readdir($filehandle)) {
    if (
$file != "." && $file != ".." ) {
        
$arch=$file;
        
$archi=$arch.'*'.$archi;
    }
}

closedir($filehandle); 

 
// paginando
$archivosfile=explode("*"$archi);
$currentpage $_SERVER['PHP_SELF']; // pagina en la que se encuentra
$total=(count($archivosfile)-1);
$maxRows_Blogdenotas 10;  // cantidad maxima de archivos 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;
$archivos array_slice($archivosfile$startRow_Blogdenotas$maxRows_Blogdenotas);

// paginando   

?>
Total Archivos: <?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 ($archivos as $archivo) { 
echo 
"<a href='$ruta$archivo'>$archivo</a><br>";
}
?>
Datos archivados del Taringa! original
0puntos
107visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
3visitas
0comentarios
Dar puntos:

Dejá tu comentario

0/2000

Autor del Post

t
taringozo🇦🇷
Usuario
Puntos0
Posts3
Ver perfil →
PosteameloArchivo Histórico de Taringa! (2004-2017). Preservando la inteligencia colectiva de la internet hispanohablante.

CONTACTO

18 de Septiembre 455, Casilla 52

Chillán, Región de Ñuble, Chile

Solo correo postal

© 2026 Posteamelo.com. No afiliado con Taringa! ni sus sucesores.

Contenido preservado con fines históricos y culturales.