Jump to content

PHP Slideshow


shazman

Recommended Posts

I am somewhat new to PHP but I have a pretty good basic understanding of what I'm doing. I'm building a site for my dad and I need a slide show for it. I looked online but could not find one to my liking so I decided to construct my own.

 

Basically what I have done so far is getting the thumbnails from a specified directory and display them on the page. What I would like to do is give each thumbnail an ID so when I click on that thumbnail, it'll display the correct photo above the thumbnails. I also want a previous and next buttons underneath and above the photo. The slide show does not have to be automatic.

 

Here's my directories:

Thumbnails: /photos/thumbs/

Photos: /photos/

 

Here's my script so far: (Found this on Google and modified it slightly.) *Note: This only gets the thumbnails

function getSlideImages ($PhotoPath) {

//path to photos
$directory = $PhotoPath;

//get all image files with a .jpg extension.
$photos = glob("" . $directory . "*.JPG");

$photoArray = '';

// create array
foreach($photos as $image) {
	$photoArray[] = "$image";
}

//shuffle array
sort($photoArray);
$numPhotos = count($photoArray);

print "Number of Thumbnails: $numPhotos<br />\n";
//display images
foreach ($photoArray as $imgsrc) {
	print "<div style=\"float:left; width:102px; height:55px; padding:4px;\"><a href=\"#\"><img src=\"$imgsrc\" border=\"1\" /></a></div>\n";
}
}

 

I am not looking for somebody to write me a script. I'm looking for somebody to help me write my own. Please give me some ideas with examples on how to do what I'm looking to do. Thank you.

 

*EDIT: I noticed after I posted this the it was in the wrong section. Sorry. Is there any way to move it?

Link to comment
https://forums.phpfreaks.com/topic/188985-php-slideshow/
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.