ShiVer Posted July 3, 2006 Share Posted July 3, 2006 Okay, I'm creating a photo gallery, here's how I would like it to work:The user updating the gallery simply connects to the FTP and uploads a folder with all the images in it. The folder name must be what they want the title of the album to be. And the first image in the folder alphabetically must be the image that they want to be the preview. Everyone follow? Good...Well, I have a loop that reads the "Albums" directory which is the one they drop they're folder into. It finds all the folders in that folder and prints them with the Folder names as titles. I also have a loop that reads all the images in each individual albums and displays the image for that "Preview". The only problem is I don't know how to make so that it Only reads the FIRST image of the album for the preview rather than pulling every image and showing the Album folders repeatedly for each image. I'll leave my code for those you understand, any help would be great, you could modify my existing or write a better way. Thanks to anyone to helps in advance. If you have any questions feel free to ask, thanks,- Ryan[code]<?php$od = opendir("albums");while($dir = readdir($od)) { if($dir[0] == '.') { continue; } $nd = opendir("albums/".$dir); while($img = readdir($nd)) { if($img[0] == '.') { continue; } echo ' <table cellpadding="2" cellspacing="1" border="0"> <tr> <td>'.$dir.'</td> </tr> <tr> <td><a href="index.php"><img src="albums/'.$dir.'/'.$img.'" width="100" height="100" border="0" /></a></td> </tr> </table> '; }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13589-photo-gallery/ Share on other sites More sharing options...
dptr1988 Posted July 3, 2006 Share Posted July 3, 2006 I don't completly understand you code, but noticed that you are skipping the '.' dir. Should you be skipping the '..' dir also? Quote Link to comment https://forums.phpfreaks.com/topic/13589-photo-gallery/#findComment-52702 Share on other sites More sharing options...
ShiVer Posted July 4, 2006 Author Share Posted July 4, 2006 That's observant but no actually, $img[0] simply contains the first character of each value... so the first character of . and .. matches, therefore it doesn't show. Quote Link to comment https://forums.phpfreaks.com/topic/13589-photo-gallery/#findComment-52814 Share on other sites More sharing options...
redarrow Posted July 4, 2006 Share Posted July 4, 2006 $dir="directoryname/";$dr=opendir($dir); // correct method for windows.closedir($dir);// correct way to close directory.example ok<?php$dir = "/etc/php5/";// Open a known directory, and proceed to read its contentsif (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; } closedir($dh); }}?> Quote Link to comment https://forums.phpfreaks.com/topic/13589-photo-gallery/#findComment-52816 Share on other sites More sharing options...
ShiVer Posted July 6, 2006 Author Share Posted July 6, 2006 I still can't seem to figure this out, I've a number of different things, and each has it's own unique problem. Any ideas from anyone? Quote Link to comment https://forums.phpfreaks.com/topic/13589-photo-gallery/#findComment-53982 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.