cooldude832 Posted June 18, 2007 Share Posted June 18, 2007 I'm trying to make a simple way to make a dynamic photo gallery function. This is my idea: First have a folder called Pics, in pics is a folder for images of different type (the criteria fun,events,nature) then in there I dump the images sorted by types in there with a basic numbering scheme of 01.jpg,02.jpg,03.jpg,04.jpg. Anyone got any ideas on a way I can read all the pictures in the subfolders and view them without having to give a count of images? Quote Link to comment https://forums.phpfreaks.com/topic/55997-reading-pictures-in-a-folder/ Share on other sites More sharing options...
cooldude832 Posted June 18, 2007 Author Share Posted June 18, 2007 can i use: while(file_exists($i.".jpg") { echo "<img src=\"".$i.".jpg\"/>"; $i++ } The basic idea? will this be a fast way? Quote Link to comment https://forums.phpfreaks.com/topic/55997-reading-pictures-in-a-folder/#findComment-276574 Share on other sites More sharing options...
only one Posted June 18, 2007 Share Posted June 18, 2007 yea that should work, it beter to try than ask as some guy always told me (cant remember who but hes a genius) id also recomend storing the info in a database (easy to work with) but its your choice Quote Link to comment https://forums.phpfreaks.com/topic/55997-reading-pictures-in-a-folder/#findComment-276708 Share on other sites More sharing options...
AndyB Posted June 18, 2007 Share Posted June 18, 2007 You can read the names into an array simply by using the glob() function. When you have a lot of images you probably want to display them a few at a time, rather than all together. Knowing how many you have will be useful for paging through them. Quote Link to comment https://forums.phpfreaks.com/topic/55997-reading-pictures-in-a-folder/#findComment-276714 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.