I have a piece of code that parses my xml file (which contains the filenames and categories of a bunch of images) into a multidimensional array.
I have a thumbnail gallery (detail.php) and when you click on a thumbnail it goes to another page that displays the full size image. The link looks like this =>
http://www.mydomain.com/image.php?article=boxbody1.
It's actually a link written on the fly contained within a 'for loop' like this =>
echo " <a href=";
echo "image.php?article=";
echo $person_data[$i]["imagetype"];
echo $x;
"imagetype" is a tag parsed from my xml file and $x increments everytime.
Just below my parser in image.php I have the following =>
$displayPic = "$article" . ".jpg";
and then further down where I want the image displayed I'm using the following line to display the image=>
<img src="<?php echo "./images/" . $displayPic; ?>">
I want to be able to navigate to the first,last, next and previous images which are really just values in my array.
My lecturer in college told me that I would end up with a piece of code similar to the following for each link =>
<?php
echo "<td class=bgwhite align=center height=52>";
echo "<a href=";
echo "imagenav.php?article=";
echo $firstOne;
echo "&mytype=";
echo $myType;
echo ">first</a></td>";
?>
The reason for the $myType variable is that when the xml file is parsed and read into the array, all of the values for imagetype are read in and we only need images of a particular type.
I will be using $firstOne, $lastOne, $prevOne and $nextOne as my variables. I remember my lexturer saying that I needed to use the 'array_values' function to return all the values in the array and that I would need to use the 'unset' function before adding or subtracting the value of the variable.
I know this is similar to the pagination technique documented here on this site but my problem really lies in iterating through my array.
Can someone please help, as my lecturer is on sick leave and I have nobody else to bounce these ideas off. Thank you.