[Fwd: Re: previous + next buttons, no DB]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



if you have all images in one directory and ONLY images in that folder

you can try something like this:

  $path = '/path/to/directory/with/images';
  $handle = opendir($path);
  while (false != ($file = readdir($handle)))
  {
if ($file != "." && $file != ".." && !ereg('.php', $file)) #excluding . and .. files and php file with this code
      {
          $images[] = $file;
      }
  }
  closedir($handle);

  $last = count($images);
  foreach($images as $key => $value)
  {
     swtich($key)
     {
         case (0):
           echo '[ next ]';
           break;
         case ($last):
           echo '[ prevous ]';
           break;
         default:
           echo '[ previous ] [ next ]';
           break;
      }
  }


I hope this will help
;)

-afan

Ashley M. Kirchner wrote:


I have a client that maintains picture galleries by simply dropping images into a directory. I have a template created that when loaded, with a specific $ID, will load the image that corresponds to that $ID. The request now is to have previous and next buttons that web surfers can click on to cycle through the rest of the images in the directory (instead of having to close that pop-up and click on another image to look at.)

What's the best way to go about this? Since I don't have a list of images in any kind of array (such as a result from DB query), I'm a bit at a loss here. Obviously if someone clicks on the first image on the gallery page, it should only have a 'next' button, and if they click the last image, it should only have a 'previous' button, but anything else on the page should have a 'previous' and 'next' button. I just don't know how to keep that relationship or how to start coding that.

   Ideas/suggestions/pointers are much appreciated here.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux