Posted by MS on 08/14/05 05:23
> > <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);
> > }
> > ?>
> >
>
> I've tried this, with no success. This is what I'm putting before any
HTML:
> <?PHP $path=$_GET[path]; ?>
>
> This is the beginning of the javascript with PHP:
>
> var fadeimages=new Array()
> <?PHP
> $thisdir = "graphics/$path/";
> $i = 0;
> if ($handle = opendir($thisdir)) {
> while (false !== ($file = readdir($handle))) {
> if ($file != "." && $file != "..") {
> echo "fadeimages[$i]=$thisdir$file\n";
> // fadeimages[0]="/graphics/shootout/200/_aaaaaaa.jpg"
> }
> $i++;
> }
> closedir($handle);
> }
> ?>
>
> I'm getting no output though, although I'm finally seeing some data in the
> output source code:
> var fadeimages=new Array()
> fadeimages[2]=graphics/NewYearsEve/images/DSCN0071.jpg
> fadeimages[3]=graphics/NewYearsEve/images/DSCN0072.jpg
> fadeimages[4]=graphics/NewYearsEve/images/DSCN0075.jpg
> fadeimages[5]=graphics/NewYearsEve/images/DSCN0079.jpg
> fadeimages[6]=graphics/NewYearsEve/images/DSCN0083.jpg
> fadeimages[7]=graphics/NewYearsEve/images/DSCN0101.jpg
> fadeimages[8]=graphics/NewYearsEve/images/DSCN0103.jpg
> I'm not sure why this is skipping over [0] and [1]... Could that be why
the
> slideshow is not starting? This script DOES work on another website.
>
Try a small tweak
var fadeimages=new Array()
<?PHP
$thisdir = "graphics/$path/";
$i = 0;
if ($handle = opendir($thisdir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "fadeimages[$i]='" . $thisdir$file . "'\n"; // addition of single
quotes around $thisdir$file
// fadeimages[0]="/graphics/shootout/200/_aaaaaaa.jpg"
$i++; // moving this line should start the array at 0
}
}
closedir($handle);
}
?>
Navigation:
[Reply to this message]
|