Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/05/2004, 15:51
Yukas
 
Fecha de Ingreso: octubre-2003
Mensajes: 46
Antigüedad: 20 años, 6 meses
Puntos: 0
De acuerdo

Perfecto, ya funciona, muchas gracias por la ayuda tiu.

Así queda el código:
Código PHP:
<?php
$thumb
="grafics/galeria/".$carpeta."/thumb";
$foto="grafics/galeria/".$carpeta."";

//contar el numero de fotos, dividiu per les columes (3). i guardar la resta
$n_fotos 0;
$direc dir($thumb); 
while (
$file $direc->read()) 

if (
eregi("\.jpg",$file)) 

$n_fotos++; 


$direc->close(); 

$n_col 3;
$files $n_fotos $n_col;
$resta $n_fotos $n_col;
$n_files floor($files);
$n_resta floor($resta);
//----------------------------------
//Ficar el nom de les imatges amb un Array
$dire dir($thumb);
$dire->read();
$dire->read();
while(
$llegir $dire->read()){
if (
eregi("\.jpg",$llegir)){
    
$a++;
    
$imagen[$a] = $llegir;
}
}
$dire->close();
//Mostrem el resultat amb una <table> de X files per X columnes
?>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td height="100" align="center">&nbsp;</td>
    <td height="100" align="center"><img src="grafics/imatges/galeria.jpg" width="200" height="70"></td>
    <td height="100" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td height="20" align="center" class="small">Fotos/<? echo "$carpeta"/*nom de la carpeta*/ ?></td>
    <td height="20" align="center">&nbsp;</td>
    <td height="20" align="center">&nbsp;</td>
  </tr>
<?
for ($f=1$f<=$n_files$f++){
    echo 
"<tr>";
    for (
$c=1$c<=3$c++){
        
$i++;
        echo 
"<td align='center' valign='top' class='small'><a href='#'-->
 onClick=\"foto('$foto/$imagen[$i]','Penya');return false\">-->
<img src='$thumb/$imagen[$i]'\"name='image' width='94'-->
height='70' border='1'></a></td>"
;
    }
    }
if (
$n_resta 0)
{
    echo 
"<tr>";
for (
$x=1$x<=$n_resta$x++)
{
$i++;
echo 
"<td align='center' valign='top' class='small'><a href='#'-->
 onClick=\"foto('$foto/$imagen[$i]','Penya');return false\">-->
<img src='$thumb/$imagen[$i]'\"name='image' width='94'-->
height='70' border='1'></a></td>"
;
// las --> se tienen que quitar y ponerlo todo junto.
}
echo 
"</tr>";
}
else {echo 
"</tr>"; }
//menu desplegable 
$path="grafics/galeria/";
$dir dir($path);
$dir->read();
$dir->read();
?>
<tr>
    <td height="20" align="center" class="small">&nbsp;</td>
    <td height="20" align="center"><form action=index2.php method=get>
Selecciona una galeria:<br> <SELECT name="carpeta">
<?
while($carpeta $dir->read()){
if (
$carpeta != "." && $carpeta != ".." && !eregi("\.",$carpeta)){
    echo 
"$carpeta";
    echo 
"<OPTION VALUE=".$carpeta.">".$carpeta."</OPTION>\n";
}
}
echo 
"</SELECT>";
echo(
"<input type=submit value=Buscar>\n");
echo(
"<input type=hidden name=id value=3>\n");
echo (
"</form>\n");
$dir->close();
?>
</td>
 <td height="20" align="center">&nbsp;</td>
  </tr>
</table><br>
¿De que otra manera lo podría hacer para que solo me mostrara las carpetas? Yo lo he hecho con && !eregi("\.",$carpeta) pero si pongo alguna carpeta que contenga un punto no se me mostrara en la lista.
PD: Retoqué algunos errores del código. Si veis alguno o veis alguna otra manera de hacerlo para optimizar el código comentarlo.
Saludos.

Última edición por Yukas; 07/05/2004 a las 18:28