image 'slideshow' script...**SOLVED**


#1

I’ve been working on an image slideshow script for my website and I’m having problems with the actual progression of the slideshow…I can’t figure out how to get it to navigate to the Next and Previous images…I’ve looked at the source of other slideshow scripts and I can’t seem to get it @_@ I don’t want to use another script, I want to build off what i have if possible…this is what i have so far:

[code] $img = 1;

$dirr = "../images/WP/";

$dir = opendir($dirr);
  $i = 1;
  $filearray = array( 0 => "0");
  while( false != ($filename = readdir($dir)))
	{ 
		if( strlen($filename) > 3 )
		{
			$tot = array_push($filearray, $filename);
			$i++;
		}
	}

closedir($dir);
	
$num = count($filearray) - 1;

$image = $dirr.$filearray[$img];[/code]

It reads the dir, gets the files in the directory (except for files under 3 characters because of my directory structure in my images dir), and adds those files to an array(which I thought would be useful o_O;…)

Thanks in advance for any help ^^;

I should add that $image at the bottom is used for the link and $num is just there to get the number of items in the array (minus the first item).


#2

I guess I could see can think of 2 way right now of doing this one…Stop using php and switch it over to Javascript, but I guess thats more than likely not either an option or something you care to do.

So I guess one way of doing it is have your to form submit buttons (previous – next). And everytime one is clicked it simply either adds or subtracts to a variable. Then when the picture gets displayed it just pulls that picture out of the array for example $pictures[$num].

That should work…I never tried that out before, but it should work.


#3

I tried that but I got really weird results @_@…I just thought of something though, and it might be worth trying. I’ll give it a shot and if it works I’ll post it.


#4

u could post the array number of the file into the url and then display the picture assotiated with that number.


#5

I solved it using the isset function to pull the variable from the url.


#6

try using > 4

because .gif = 4 it would need to be x.gif etc to be added then.