Reply to Re: [PHP] Re: previous + next buttons, no DB

Your name:

Reply:


Posted by Philip Hallstrom on 10/20/97 11:24

>> Ashley,
>>
>> How are you creating the gallery page? You must be reading the filenames in
>> the directory and producing an <img> for each one. Can you create an array
>> of those filenames, save it to session (or generate it each time), and
>> iterate through them?
>>
> 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.

Change it. Remove all the hardcodings from index.html. Instead create
another data file that contains the list of images (and the order) you
want them displayed. Easier for you if that file is a PHP file that looks
something like:

$img_array = array(
"img1",
"img3",
"img2",
);

But it could just as easily look like this:

img1
img3
img2

Note that I'm only putting in the "basename" of the image, not the full
name. Hopefully you can determine the path to the thumbnail and full
image from this basename.

If you can't make it look like this:

img1thumb.jpg img1.jpg
....

Then turn your index.html into a index.php file that includes (or
processes) this data file. Now you've got an array you can loop through
to display the thumbnails.

Change your popup.php page to read that data file in as well. And now you
can loop through it to find the image you're viewing. Keep track of a
counter and if that counter is greater than zero, display a previous link.
If it's less then the total count of the array minus one, display a next
link.

I'd take it a step further still and have each separate index.php include
a master index.php (same for popup.php) so that the only thing a specific
directories index.php contains is:

include_once("/path/to/master/index.php");

That way you can make global code changes without touching all the files.

Good luck!

-philip

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация