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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.