PHP Image Gallery


I want to add a multi-page image gallery to my website but, if possible, I’d like it to be done in as simple a way as possible, without requiring HTML for each page… and without requiring any SQL etc.

So… at the moment, i’m using hardcoded tags, with 001 being anything from 001 to 999. I display 12 or 15 images per page, all sequentially numbered.

I’m sure that there must be a way to do this nicely in PHP with a left and right arrow (appearing/disappearing depending on whether you’re at the start, middle or end).

Can anyone point me at a good script for doing this?

Thanks in advance,

Something like this?


$numberofimagesperpage = 15;

$start = 1;
if (isset($_GET[‘start’]) && intval($_GET[‘start’]) > 0) { $start = intval($_GET[‘start’]); }

for ($i = $start; $i < ($start + $numberofimagesperpage); $i++) {
echo “”;

if ($start > 1) {
echo “Previous Page”;

if (file_exists($start + $numberofimagesperpage + 1)) {
echo “Next Page”;

Ah, that looks like the sort of thing I need. With $i instead of $start inside the echo I reckon and a small change to file_exists, that should work :-)

Sponsor our Newsletter | Privacy Policy | Terms of Service