Christian F. Posted December 20, 2012 Share Posted December 20, 2012 Yes, but the code I posted is just an example. Not meant for copy-pasting into your own code, but as a base on which you can build your own function. Quote Link to comment https://forums.phpfreaks.com/topic/272135-display-list-of-folders-and-link-to-individual-pages/page/2/#findComment-1400624 Share on other sites More sharing options...
mallen Posted December 20, 2012 Author Share Posted December 20, 2012 (edited) Shouldn't this (glob ($directory, GLOB_ONLYDIR) as $dir) be this? (glob ($directory, GLOB_ONLYDIR) as $pdf) and this echo the list of pdf files? Edited December 20, 2012 by mallen Quote Link to comment https://forums.phpfreaks.com/topic/272135-display-list-of-folders-and-link-to-individual-pages/page/2/#findComment-1400626 Share on other sites More sharing options...
mallen Posted December 20, 2012 Author Share Posted December 20, 2012 (edited) 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. Edited December 20, 2012 by mallen Quote Link to comment https://forums.phpfreaks.com/topic/272135-display-list-of-folders-and-link-to-individual-pages/page/2/#findComment-1400658 Share on other sites More sharing options...
mallen Posted December 20, 2012 Author Share Posted December 20, 2012 (edited) 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); } Edited December 20, 2012 by mallen Quote Link to comment https://forums.phpfreaks.com/topic/272135-display-list-of-folders-and-link-to-individual-pages/page/2/#findComment-1400665 Share on other sites More sharing options...
mallen Posted December 20, 2012 Author Share Posted December 20, 2012 Ok got it to work. (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); } } Quote Link to comment https://forums.phpfreaks.com/topic/272135-display-list-of-folders-and-link-to-individual-pages/page/2/#findComment-1400668 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.