complex05 Posted December 15, 2006 Share Posted December 15, 2006 hello,I'm trying to make a basic image gallery script, where images are displayed from a while(readdir()), and each image is linked to the next image in the dirso basically it'll be like gallery.php?image=1.jpg, then the image on this page will be linked to gallery.php?image=2.jpghow do I tell the script what the next image in the directory is? here is my code:[code]<?phpif ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<a href=gallery.php?image=???><img src=gallery/$file border=0></a>\n"; } } closedir($handle);}?> [/code] Link to comment https://forums.phpfreaks.com/topic/30761-solved-image-gallery-script/ Share on other sites More sharing options...
complex05 Posted December 15, 2006 Author Share Posted December 15, 2006 bump Link to comment https://forums.phpfreaks.com/topic/30761-solved-image-gallery-script/#findComment-141775 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Author Share Posted December 15, 2006 bumpin again Link to comment https://forums.phpfreaks.com/topic/30761-solved-image-gallery-script/#findComment-141809 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Author Share Posted December 15, 2006 3rd bump? :( Link to comment https://forums.phpfreaks.com/topic/30761-solved-image-gallery-script/#findComment-141827 Share on other sites More sharing options...
taith Posted December 15, 2006 Share Posted December 15, 2006 something to that effect maybe?[code]<?phpif($handle = opendir('.')){ while (false !== ($file = readdir($handle))){ if($file != "." && $file != ".."){ $images[]=$file; } } closedir($handle);}$current=$_GET[image];if(empty($current)) $current=1;$prev=$images[$current-1];$image='<img src="gallery/'.$images[current].'">';$next=$images[$current+1];?>[/code] Link to comment https://forums.phpfreaks.com/topic/30761-solved-image-gallery-script/#findComment-141834 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Author Share Posted December 15, 2006 ...duh. Sorry for the dumb post haha, brain fart :)Thanks taith :) Link to comment https://forums.phpfreaks.com/topic/30761-solved-image-gallery-script/#findComment-141849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.