|
Posted by Tyrone Slothrop on 08/12/05 03:45
On 11 Aug 2005 17:18:52 -0700, "LAshooter" <LAshooter@hotmail.com>
wrote:
>I'm still having no luck getting a slideshow program to work
>dynamically. I have a client sending me batches of photos of various
>events, and I'm uploading them into individual folders
>(/graphics/NewYearsEve, /graphics/EasterParty, etc).
>
>The script that I like is a javascript that cycles through images
>defined as below:
>
>var fadeimages=new Array()
>//SET IMAGE PATHS. Extend or contract array as needed
>fadeimages[0]="/graphics/shootout/shootout01.jpg"
>fadeimages[1]="/graphics/shootout/shootout02.jpg"
>fadeimages[2]="/graphics/shootout/shootout03.jpg"
>fadeimages[3]="/graphics/shootout/shootout04.jpg"
>etc...
>
>I am trying to create one page (i.e. "slideshow.php") that will do this
>when passed a variable in a link (i.e. A
>HREF="slideshow.php?path=NewYearsEve"... Ideally that would tell the
>slideshow script to look in /graphics/NewYearsEve/ for the photos, and
>either read the filenames to insert in the above script or perhaps
>count the number of files and then echo the above up to that number.
>(The latter would obviously require renaming uploaded files to
>comparable numbers.) So far I have had no luck borrowing similar code
>from PHP.net or other code libraries, so I'm probably not approaching
>this correctly. Does anyone have any recommendations on how to approach
>this situation?
>
>Thanx,
>Wm
Wm:
Create your array in PHP:
(based on http://www.php.net/manual/en/function.readdir.php)
<script>
var fadeimages=new Array()
<?php
$thisdir = '/path/to/images';
$i = 0;
if ($handle = opendir($thisdir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "fadeimages[$i]=$thisdir$file\n";
}
$i++;
}
closedir($handle);
}
?>
Navigation:
[Reply to this message]
|