With the help of various sources and answers from users of PHPBuilder (thanks) I have managed to get an image gallery working.
I am now thinking about including some 'next' and 'prev' links on the page that will dynamically link to the next or previous image, depending on what image the user is viewing.
The gallery is a simple two column layout, on the right are the thumbnails which link to an image like this:
<a href="index.php?page=portfolio&image=005">
calling up the image and placing into the left column which holds the large image:
echo "<img src='$image.jpg' alt='{$caption[$image]}' />";
You can view the gallery here
The images will remain named as 001, 002, 003 ... 0012. I will simply replace them as and when.
And, to my question! how will I implement a system where depending what image the user is viewing a next or prev button will do just that...
I was thinking something like this:
<?php
$next = $image + 1;
$prev = $image - 1;
?>
<a href="http://www.mattkirwan.co.uk/portfolio/index.php?page=portfolio-test&image=<?php echo("$next"); ?>">NEXT</a>
<a href="http://www.mattkirwan.co.uk/portfolio/index.php?page=portfolio-test&image=<?php echo("$prev"); ?>">PREV</a>
but this makes the next image JUST '2' for example - it drops the '00' and of course it will keep going onto 13, 14 - when there are only 12 images.
How do I keep the '00' in the increment (I could rename the images and links though) and how do I stop next and prev links from going past 001 and 012 respectively?
Your help is greatly appreciated