Jump to content

Display List Of Folders And Link To Individual Pages


mallen

Recommended Posts

Can anyone else help? I have been struggling with this for 3 days. The more I look at it not sure (how is currently written) how it knows I want only pdf files to be listed in the second function.

 

My folder struccture is products/category1/product1/product2....category2/product1/product2 and so on. I already can get it to list the category folders as links.

I tried this function and it outputs it if I do a var_dump($dir) but can't get it to echo the values.

function list_directories () {
if (!empty ($_GET['folder'])) {
 $dir = 'products/' . $_GET['folder'];

} else {
 $dir = 'somevalue';

}
$images= glob($dir . "*.jpg");

foreach($images as $image)
{
echo $image;
}
var_dump($dir);
}

Ok got it to work. :happy-04: (somewhat) I left off that slash/ on line 6. It now displays the image according to the link I click. Now I need to work on passing the variable for the pdf file. Because all it checks is value of 'folder'

function list_directories () {
if (!empty ($_GET['folder'])) {
    $dir = 'products/' . $_GET['folder'];

} else {
    $dir = 'somevalue';

}
$images = glob($dir . "/*.jpg");

foreach($images as $image)
{
echo basename($image);
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.