you can easily do this:
Code:
$i = 1;
$myarray = array();
$exists = file_exists('brewery' . $i . '.jpg');
while ($exists = true)
{
array_push($myarray, 'brewery' . $i . '.jpg');
$exists = file_exists('brewery' . $i . '.jpg');
$i++;
};
This will load up an array of images you are interested in. Note that this code does not pad your numbers with zeros first, ie, it will be brewery1.jpg not brewery01.jpg
Then, in your display code you could put:
Code:
if (in_array($id2 . '.jpg', $myarray))
{
// display your image here
};
then, in your link code you can:
decrement or increment the variable of the image you are looking at by using $id2-- , $id2 = $id - 1 , or $id2++ or $id2 = $id2 + 1;
and then display the links, or only display the links if they are within range. There is an array_count() I believe that lets you know how many items you have in your array.
and in your main code that displays the image, and act on it if it does or doesn't (eg, just display the first/last image in your array if they go above or below the range of image numbers).
This is
just one way of doing it. May not be efficient, but I thought it up off the top of my head.