Jump to content

Go through images in a folder.


franzwarning

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.