1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Doubtfuls on a gallery

Discussion in 'PHP' started by reeda80, Jun 12, 2009.

  1. #1
    Hello to everyone,
    I write you from Italy so...pardon for my english!
    I've a problem with a gallery, I explain better...
    I need a way for:
    read the photos in n°x subdirectory and send the photos (with caption) in a flash file that will be the gallery.
    Now I've do a script that read in my "Mother Directory" and read the sub director and the file inside them.
    and now... I'm stopped!
    How can I do?
    I put here the code that I've do... but give an error!
    
    function dir_reader($dir, &$images, &$subdirs) 
    {
    global $defdir;
    if($dir != $defdir)
    {
    $dir = $defdir."/".$dir;
    }
    if ($handle = opendir($dir)) 
    {		
    while (false !== ($file = readdir($handle))) 
    {
    if ($file != "." && $file != "..") 
    {
    $filemane='a href="My_Gallery"';
    list($filename, $ext) = explode(".", $file);
    if(!is_dir($dir.'/'.$file)) 
    {
    if($ext == "jpg" || $ext == "jpeg")
    {
    $images[] = $dir."/".$file;
    }
    }
    else
    {
    $subdirs[] = "<a href='?My_Gallery=".$file."'>".$file."</a>";
    }
    }
    }
    closedir($handle);
    }
    }
    
    //Nome della cartella madre
    $defdir = './My_Gallery';
    if(!isset($_GET['My_Gallery']))
    {
    $dir = $defdir;
    }
    else
    {
    $dir = $_GET['My_Gallery'];
    }
    $images = array();
    $subdirs = array();
    dir_reader($dir, $images, $subdirs);
    ?>
    <table border="2">
    <tr>
    <td>
    <?php
    // Da rivedere ciclo sull'array $subdirs
    print("<pre>");
    print_r($subdirs);
    print("</pre>");
    if(isset($_GET['My_Gallery']))
    {
    print("<a href='".$_SERVER['PHP_SELF']."'>indietro</a>");
    }
    ?>
    </td>
    <td>
    <?php
    // Da rivedere ciclo sull'array $images per ottenere la gallery di immagini
    print("<pre>");
    print_r($images);
    print("</pre>");
    ?>
    </td>
    </tr>
    </table>
    
    PHP:
    Thanks to all and a Good day!
     
    reeda80, Jun 12, 2009 IP