Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/11/2007, 10:19
nevergame
 
Fecha de Ingreso: julio-2006
Ubicación: sevilla
Mensajes: 251
Antigüedad: 17 años, 10 meses
Puntos: 5
paginar contenido directorio

Hola tengo un problema tengo un directorio con un numero indeterminado de fotos y necesito que se muestre en web de forma paginada al estilo mysql, con un anterior y siguiente, con un salto de 9 fotos por pagina he intendao esto pero me he atascado

Código PHP:
$galid=$HTTP_GET_VARS["id"];
//consulta todas las galerias


        $consulta= "Select * from galerias where galId = '".$galid."'";
        
        $result = mysql_query($consulta,$link);
      
        while ($row = mysql_fetch_array($result)) {
             
            $dir = $row['galDirectorio'];
            $nombre=$row['galNombre'];
            $descripcion=$row['galDescripcion'];
            
            
        }
        
    
if(!isset($HTTP_GET_VARS["pagb"]) && !isset($HTTP_GET_VARS["pags"])){
$path = "/home/cccs/www/ncn/fotos/".trim($dir);
$_SESSION['total']=0;
//cuento el numero de ficheros que contiene
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
    if($file != "." && $file != "..") {
        
        $_SESSION['total']++;
    }
}
closedir($dh);
}
//echo $_SESSION['total'];
$max_pag=0;
$b=1;
$s=1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <title>Galeria Fotos Centro Norteamericano de Estudios Interculturales</title>
    <link rel="stylesheet" href="estilos_2.css" type="text/css" />
    <link href="estilo_g.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<div id="principal">
    
<div id="titulo">
<?php echo strtoupper(" Centro Norteamericano de Estudios Interculturales");?>
<br />-GALER&Iacute;A FOTOS <?php echo strtoupper($nombre);?>-
<br>
</div>

<div id="menu" style="height:50px; width:300px;">
    
    <?php echo "<a href='galeria.php?id=".$galid."&pagb=".$s."'  <input  type='button' name='anterior'  value='<< Anterior'  class='boton'></a>"?>
    <?php echo "<a href='galeria.php?id=".$galid."&pags=".$b."'  <input  type='button' name='siguiente'  value='Siguiente >>'  class='boton'></a>"?>
    
    </div>
<?php
  
//abrimos el directorio
$dh opendir($path);


if(!isset(
$HTTP_GET_VARS["pagb"]) && !isset($HTTP_GET_VARS["pags"])){
$_SESSION['inicio']=0;
$_SESSION['fin']=$max_pag;
}else{

if ( isset(
$HTTP_GET_VARS["pags"]) && $_SESSION['fin']<$_SESSION['total']){
echo 
"SUMAR";
echo 
$_SESSION['inicio']=$_SESSION['inicio']+1;
echo 
$_SESSION['fin']=$_SESSION['fin']+1;
}

if (isset(
$HTTP_GET_VARS["pagb"]) && $_SESSION['inicio']>){
echo 
"RESTAR";
echo 
$_SESSION['inicio']=$_SESSION['inicio']-1;
echo 
$_SESSION['fin']=$_SESSION['fin']-1;
}
}

$in=$_SESSION['inicio'];
while ((
$file readdir($dh)) !== false) {
    if(
$file != "." && $file != "..") {
     
     if (
$in<=$_SESSION['fin']){
        echo 
"<div class='contenedorfoto'><a href='#'><img src='fotos/".$dir."/".$file."' border='0' width='426' height='320' /><br /><span>".$descripcion."  ".$file."</span></a></div>";
        }
       
$in++;
    }
}
closedir($dh);

?>
espero que me puedan ayudar