franzwarning Posted March 11, 2011 Share Posted March 11, 2011 Hi, I want to be able to click on the photo and go to the next one in a folder. I have this code already, I just am not quite sure how to finish it. -George <?php $count = $_GET['count']; $dir = "images"; $names = array(); $handle = opendir($dir); while ($name = readdir($handle)){ if(is_dir("$dir/$name")) { if($name != '.' && $name != '..') { echo "directory: $name\n"; } } elseif ($name != '.DS_Store' ) { $names[] = $name; } } closedir($handle); $numberofitems = count($names); $numberofitems--; if ($count <= $numberofitems){ echo "<p>"; echo "<img src='images/".$names[$count]."'>"; } else {echo "end";} ?> Link to comment https://forums.phpfreaks.com/topic/230367-go-through-images-in-a-folder/ Share on other sites More sharing options...
mattal999 Posted March 11, 2011 Share Posted March 11, 2011 Well, you simply need a hyperlink incrementing the $count variable. Replace: echo "<img src='images/".$names[$count]."'>"; With: echo "<a href='?count=".($count + 1)."'><img src='images/".$names[$count]."'></a>"; Link to comment https://forums.phpfreaks.com/topic/230367-go-through-images-in-a-folder/#findComment-1186334 Share on other sites More sharing options...
franzwarning Posted March 11, 2011 Author Share Posted March 11, 2011 You just made my day. Link to comment https://forums.phpfreaks.com/topic/230367-go-through-images-in-a-folder/#findComment-1186340 Share on other sites More sharing options...
mattal999 Posted March 11, 2011 Share Posted March 11, 2011 You just made my day. Glad I could help Link to comment https://forums.phpfreaks.com/topic/230367-go-through-images-in-a-folder/#findComment-1186343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.