Jump to content

Selecting images from directory


deth4uall

Recommended Posts

I want to select images from a directory and paginate them so I can call something similar to images.php?stack=2 and have the set images displayed (7-12 for example)...

 

<?php
$stack 1[] = "/images/01.jpg";
$stack 1[] = "/images/02.jpg";
$stack 1[] = "/images/03.jpg";
$stack 1[] = "/images/04.jpg";

$stack 2[] = "/images/05.jpg";
$stack 2[] = "/images/06.jpg";
$stack 2[] = "/images/07.jpg";
$stack 2[] = "/images/08.jpg";

if ($_GET['stack'] == 1)
{for ($i = 0; $i < 4; $i ++)
    {echo "<img src='{$stack1[$i]}'/>";
    }
}
elseif ($_GET['stack'] == 2)
{for ($i = 0; $i < 4; $i ++)
    {echo "<img src='{$stack2[$i]}'/>";
    }
}
?>

 

That basically should do the job :)

I want the script to look through a directory and list images from that...

An array would not work with what I need to do, due to the fact that I am trying to create a dynamic gallery which I don't want to have to go through constantly and update when I upload a new image...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.