deth4uall Posted September 6, 2009 Share Posted September 6, 2009 I want to select images from a directory and paginate them so I can call something similar to images.php?stack=2 and have the set images displayed (7-12 for example)... Quote Link to comment https://forums.phpfreaks.com/topic/173332-selecting-images-from-directory/ Share on other sites More sharing options...
cs.punk Posted September 6, 2009 Share Posted September 6, 2009 I want to select images from a directory and paginate them so I can call something similar to images.php?stack=2 and have the set images displayed (7-12 for example)... <?php $stack 1[] = "/images/01.jpg"; $stack 1[] = "/images/02.jpg"; $stack 1[] = "/images/03.jpg"; $stack 1[] = "/images/04.jpg"; $stack 2[] = "/images/05.jpg"; $stack 2[] = "/images/06.jpg"; $stack 2[] = "/images/07.jpg"; $stack 2[] = "/images/08.jpg"; if ($_GET['stack'] == 1) {for ($i = 0; $i < 4; $i ++) {echo "<img src='{$stack1[$i]}'/>"; } } elseif ($_GET['stack'] == 2) {for ($i = 0; $i < 4; $i ++) {echo "<img src='{$stack2[$i]}'/>"; } } ?> That basically should do the job Quote Link to comment https://forums.phpfreaks.com/topic/173332-selecting-images-from-directory/#findComment-913664 Share on other sites More sharing options...
deth4uall Posted September 6, 2009 Author Share Posted September 6, 2009 I want the script to look through a directory and list images from that... An array would not work with what I need to do, due to the fact that I am trying to create a dynamic gallery which I don't want to have to go through constantly and update when I upload a new image... Quote Link to comment https://forums.phpfreaks.com/topic/173332-selecting-images-from-directory/#findComment-913666 Share on other sites More sharing options...
DavidAM Posted September 6, 2009 Share Posted September 6, 2009 The function you are looking for is "glob". It will return an array of filenames that match a specified pattern. http://us3.php.net/manual/en/function.glob.php Quote Link to comment https://forums.phpfreaks.com/topic/173332-selecting-images-from-directory/#findComment-913686 Share on other sites More sharing options...
deth4uall Posted September 7, 2009 Author Share Posted September 7, 2009 can you show me an example??? Quote Link to comment https://forums.phpfreaks.com/topic/173332-selecting-images-from-directory/#findComment-913894 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.