October 13, 201411 yr Hi guys, I have this script to echo out files in a directory for fancybox, I'm getting a strange result here on this page (rest of the site is not done using php; it has been tediously coded). <?php // settings $base = "../images/alb"; $thumbs = "thumbs"; $files = scandir($base); unset($files[0], $files[1]); unset($files[array_search('.DS_Store', $files)]); unset($files[array_search('thumbs', $files)]); $chunk = array_chunk($files, 10000); foreach($chunk as $i => $filearray) { foreach ($filearray as $file) { echo " <a class=\"fancybox\" rel=\"group\" href=\"$base/$file\"><img src=\"$base/$thumbs/$file\" alt=\"\"/></a> </div>"; } } ?> The first few pics seem to escape the containing divs, then it's fine. I thought it may be the if else statement, which was originally set to 10 files then do something different, I've changed that now to 10,000 so it cannot be that any more as there are only about twenty pics in each directory.
October 13, 201411 yr Hi guys, I have this script to echo out files in a directory for fancybox, I'm getting a strange result here on this page (rest of the site is not done using php; it has been tediously coded). <?php // settings $base = "../images/alb"; $thumbs = "thumbs"; $files = scandir($base); unset($files[0], $files[1]); unset($files[array_search('.DS_Store', $files)]); unset($files[array_search('thumbs', $files)]); $chunk = array_chunk($files, 10000); foreach($chunk as $i => $filearray) { foreach ($filearray as $file) { echo " <a class=\"fancybox\" rel=\"group\" href=\"$base/$file\"><img src=\"$base/$thumbs/$file\" alt=\"\"/></a> </div>"; } } ?> The first few pics seem to escape the containing divs, then it's fine. I thought it may be the if else statement, which was originally set to 10 files then do something different, I've changed that now to 10,000 so it cannot be that any more as there are only about twenty pics in each directory. Idk if your aware but your missing an opening div inside your foreach loop just before <a class=\"fancybox\" you only have the closing div Edited October 13, 201411 yr by webdesigner93
October 13, 201411 yr Author Thanks Webdesigner, problem solved. I'm out of my depth with this, I'm just trying to learn Javascript in my spare time, hopefully I can get to this level one day. Massive thanks again.
October 13, 201411 yr Thanks Webdesigner, problem solved. I'm out of my depth with this, I'm just trying to learn Javascript in my spare time, hopefully I can get to this level one day. Massive thanks again. Well it's not really you failing to be at a certain level it's just you simply forgot the opening div this can happen in plain old html without php as well Glad you got it sorted
October 13, 201411 yr Also to clean up your code some you could just try this while (false !== ($file = readdir("pathtodirectory"))) { echo " <div> <a class=\"fancybox\" rel=\"group\" href=\"$base/$file\"><img src=\"$base/$thumbs/$file\" alt=\"\"/></a> </div>"; } not exactly tested but should work Edited October 13, 201411 yr by webdesigner93
Create an account or sign in to comment