PHP image gallery help (echo (sub)folder)

I have made a simple PHP image gallery where I save each users pictures in a folder with their usernames.
Like this for example:

To show the users pictures I use a code that shows all files in the folder images\USERNAME\thumbs\

But I have been trying to figure out how to make a link on each thumbnail so they can click on it to see the original picture.

I NEED HELP, can’t figure it out!

 <table border="0" width="600">
<? $sessionnavn = $_SESSION['SESS_FIRST_NAME'];
echo '<h1>'.$sessionnavn.'`s album</h1>'; 

$files = glob("images/".$sessionnavn."/thumbs/*.*"); for ($i=0; $i<count($files); $i++) { $num = $files[$i];

echo '<img src="'.$num.'" alt="Opplastet bilde"></a>'."&nbsp;&nbsp;"; } ?>


You can use str_replace() function and apply it to thumbnail image path:

echo ‘Opplastet bilde’."  ";[/php]

p.s. noticed small bug in your html code: you have opening

but closing is


<? $sessionnavn = 'My'; echo '

'.$sessionnavn.' album

'; ?>
        $files = glob("images/".$sessionnavn."/thumbs/*.*");
        for ($i=0; $i<count($files); $i++) {
            $num = $files[$i];
            echo '<a href="#"';
            echo '"'.$num.'","myimage","width=600,height=600")';
            echo '><img src="'.$num.'" alt="Opplastet bilde" width="100" height="100"></a>'."&nbsp;&nbsp;";
        } ?>



Sponsor our Newsletter | Privacy Policy | Terms of Service