Hi everyone!
I was looking for some help with my PHP snippet that I’m using.
Basically the code automatically looks through a thumbnail folder on my website and essentially sorts them and displays them as is. Now I got that portion to work great because my site is now displaying all the thumbnails as I wished them to be displayed. Where my issue falls at this point is having them link to a specific page each. Here is my code and maybe I can explain better once you have a look;
<?php
$dir = "../corq media 3.1/thumbnail/";
$dh = opendir($dir);
while($filename = readdir($dh))
{
$filepath = $dir.$filename;
if(is_file($filepath) and ereg("\.jpg" ,$filename))
{
$gallery[] = $filepath;
}
}
sort($gallery);
foreach($gallery as $image)
{
echo "<article class ='????'><a class ='shrink' href='$image'><img src='$image' height='310' width='355' /></a></article>";
}
?>
Okay so if you look at where it says echo everything works fine however what I am trying to do is have the “href” change to a specific link to match which thumbnail is shown.
I attempted a few things…created a var $linkExten which basically displayed the beginning portion of the echo and tried to have the href call the $filename and created a new while loop that ended the filename off with .php however that didn’t work. To be honest I have tried a few methods and nothing seemed to work…
Any help would be greatly appreciated.
***EXTRA INFO IF IT HELPS: I have a thumbnail folder on in my root directory that holds all the thumbnails. I have an img folder which holds the same images however the full sizes of them with the same names as the corresponding thumbnail version.