Ver Mensaje Individual
  #6 (permalink)  
Antiguo 13/03/2008, 10:19
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 20 años, 4 meses
Puntos: 2135
Re: gererar tabla para imagenes

Prueba así tu código:
Código PHP:
<?php
// leer imagenes en el diractorio fotos
$dir = "fotos/";
$explorar = scandir($dir);
$totalFotos = count($explorar);
$total = 0;
for (
$k = 0; $k<=$totalFotos; $k++) {
    if (
$explorar[$k] != "." && $explorar[$k] != ".." && $explorar[$k] != "index.php") {
    
$total++;
    }    
}

$list_ignore = array('.','..','index.php');
if(
$getdir = opendir($dir)){
    echo 
"<table border='1'>";
    
$col = 5;
    
$i = 1;
    while((
$foto = readdir($getdir)) !== false) {
            
$resto = ($i % $col);
            if(
$resto == 1){ echo "<tr>"; }
            echo 
"<td colspan='$col'>";
            if(!
in_array($foto, $list_ignore)){
                echo 
"Nombre: $foto: Tipo: ". filetype ($dir . $foto) . "<br>";
                echo 
"<img src='$dir$foto'>";
            }
            echo 
"</td>";
            if(
$resto == 0){echo "</tr>";}            
        }
        if(
$resto <> 0){
            
$ajust = $col - $resto;
            for(
$j = 0; $j < $ajust; $j++) {echo "<td>&nbsp;</td>";}
            echo 
"</tr>";
        }
        
$i++;
    }
    echo 
"</table>";
    
closedir($getdir);
}
?>
Saludos.