RE: Re: previous + next buttons, no DB

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

 



>     Say the images are in a folder called /gallery/
> 
>     Within that, I have an index.php that is manually coded to have 
> thumbnails of the images displayed in a grid.  Important to note: 
> they're in a very specific (artistic) order.  Each one of those 
> thumbnails is linked to one and the same popup.php file that 
> is simply 
> another php file that expects an $ID passed to it.  That $ID, which 
> again is hard coded in index.html, tells popup.php which file to 
> display.  (that $ID is basically the file name of the image, so I can 
> append it to the <img /> tag as the page loads.
> 
>     So you see, I have no array of anything.  The index.html 
> file gets 
> manually edited every time something is added or removed.  
> This is why 
> I'd like a programmatic way of a) generating that file, so that the 
> client can add/remove images as they see fit, and b) be able to have 
> prev/next buttons on the popup window.
> 

Ashley,

If you use a naming convention for the files in /gallery/ that coincides
with the artistic order in which they are to be displayed, then Greg's
simple (yet elegant, and expertly coded) directory listing method would work
like a charm.

Say your files are named like this:

100.jpg  // 1st file to be displayed
200.jpg  // 2nd file...
300.jpg  // 3rd file...
...

Using Greg's code, you could pull the enitire directory into an array:

$a = array();
$d = dir( '.' );
while( false !== ( $e = $d->read() ) )
{
  $a[] = $e;
}
$d->close();

Since you now know which picture you are currently displaying, you can get
the previous and next pictures from the array and code your "Next" and
"Previous" buttons.  If the pic you are displaying happens to be the first
or last in the array, don't display the corresponding link.

Of course, this all depends on your naming convention agreeing with your
display order.

JM

-- 
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