PHP in a dynamic (PHP) slideshow

Hello. I have a piece of coding, yet for the life of me, I have no idea how to accomplish the next step.
I have a code that allows me to grab images from any folder I choose and then use them in a slideshow - it automatically recognizes the images as images (in other words, I don’t need to specify which images I want to use).

However, I do not understand how to dynamically use those pictures in my slideshow code:

[php]

<?php //path to directory to scan. $directory = "images/";
//get all image files with a .jpg extension.
$images = glob("" . $directory . "*.jpg");
 
$imgs = '';
// create array
foreach($images as $image){ $imgs[] = "$image"; }
 
//shuffle array
shuffle($imgs);
 
//select first 20 images in randomized array
$imgs = array_slice($imgs, 0, 20); 

?>

<?php //display images foreach ($imgs as $img) { echo ""; } ?>
[/php]

Where you see my php coding, usually you would have divisions of pictures. Right now, all it does is display the first image (with the rest underneath). Then, when it changes images, it just goes blank.

I will post my js code as well (in case this is of any help).

[code]$("#slideshow > div:gt(0)").hide();

setInterval(function() {
$(’#slideshow > div:first’)
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo(’#slideshow’);
}, 3000);[/code]

Have you verified by viewing the source that the other images are actually being output to the browser? If they are then this is not likely a php problem but rather a css or javascript issue. PHP doesn’t effect anything after it’s output to the borwser, so the behavior after that is not based on php.

Yes, they images are without a doubt coming from the source I indicate in my code.

Really? You truly think this would be a javascript issue? I doubt it would be css. I cannot fathom how it would be so.

This is how I see it: the dynamic aspect I am trying to add is not added because I am not creating a loop of sorts (but, I have a LOT of difficulty with loops and the like - so yes, it may be javascript). In this case, what do I do with this post? I assume that I should try a javascript forum? Or do you know if people in phphelp have knowledge in this type of problem?

Btw, thank you for your reply, I appreciate it.

Yes, they images are without a doubt coming from the source I indicate in my code.
That's not what I mean, did you do a right click and view the source of the page to make sure all the are actually being echoed to the browser? If they are then try a javascript forum, there maybe a section on this forum for javascript but I have not looked.

Yes they are, all of them lol. Which is the biggest problem I have. What I mean is, you have one picture, followed (beneath) by ALL the others. Then, they disappear altogether - since it is an autoplaying slideshow, it tries to go to the next slide… being nothing :confused: Even then, it shouldn’t be blank. Worst comes to worst, it should be the same lots of pics reappearing.

Sponsor our Newsletter | Privacy Policy | Terms of Service