I have been asked to create a Slideshow of all the images in a certain directory with just a "PREVIOUS | NEXT" link.

the image would display on the same page, and the filename minus the extension would appear underneath it in bold, as a H3.

like this:


previous | next

I M A G E

image name
I have a script which shows all the files ina directory and lists the names, as well as the image upon clicking:

PHP Code:
<?php 
    
if ($_GET['image']) {
    echo 
'<img src="'.$_GET['image'].' " >';
    } 
?></div>
<?php

   
# Do we have a path? if not, it's the current directory
   
$path $_GET["path"];
   if( !isset( 
$path ) || $path == "" )  {
     
$path ".";
   }

   
# Initialise list arrays, directories and files separately and array counters for them
   
$d_arr = array(); $d 0;
   
$f_arr = array(); $f 0;

   
# Open possibly available directory
   
if( is_dir$path ) ) {
     if( 
$handle opendir$path ) ) {
         while( 
false !== ( $file readdir$handle ) ) ) {
           
# Make sure we don't push parental directories or dotfiles (unix) into the arrays
           
if( $file != "." && $file != ".." && $file[0] != "." ) {
               if( 
is_dir$path "/" $file ) )
                 
# Create array for directories
                 
$d_arr[$d++] = $file;
               else
                 
# Create array for files
                 
$f_arr[$f++] = $file;
           }
         }
     }
   }

   
# Wrap things up if we're in a directory
   
if( is_dir$handle ) ) closedir$handle );

   
# Sort and reset the arrays
   
asort$d_arr ); reset$d_arr );
   
asort$f_arr ); reset$f_arr );

   
# Print the directory list
   
for( $i=0$i count$d_arr ); $i++ ) {
     
# Print with query string
     
print "<a href=\"?path=" $path "/" $d_arr[$i] . "\">" $d_arr[$i] . "</a>/<br />\n";
   }


foreach(
$f_arr as $filename) {
# Extract 'name' part
$name pos(explode('.'$filename));
# Only print path and filename
print "<br/><a style='font-size:90%;' href='$path/dragees.php?image=$filename'>$name</a>";
}

   
?>
I'm sur eI'd be able to use 90% of that script above in this new one, but how would it be done? I'm sure its really easy if you know how its done, but I dont!

I started on the "previosu | next" link, using this simple code:

PHP Code:
//the link for the next image should be the value of the image shown, increased by one.
$nextimg $img 1;

$img /*image url - how to show?*/;

$link "<a href=\"'.$nextimg.'">NEXT</a>";

echo 
$link
but that is as far as I got! where do I go form here, any suggestions?

thanks in advance!