oha055 Posted February 4, 2012 Share Posted February 4, 2012 Hi! I am currently making a really simple photo blog. The query fetches every reference to the images which are stored on the server. I have a problem when it comes to dynamically cycling through these though. After running the query, I store each image reference in a twodimensional array like this: [["id"], ["date"], ["title"], ["filename"]] (an Array of Arrays). The image displays just fine by doing this: $pointer; //starting from the last element (image) in the array <img src="images/gallery/<?php echo $images[3][$pointer] ?>" alt="<?php echo $images[2][$pointer] ?>"> The problem is that, when I update the pointer, say for instance pointer++, the current image on the screen doesnt update. I know for a fact that the pointer updates, because I have echoed it. The basic idea is to have a previous and next link just under the image, so that the viewer can cycle the available images. Any help is greatly appreciated Link to comment https://forums.phpfreaks.com/topic/256386-dynamically-changing-image/ Share on other sites More sharing options...
Pikachu2000 Posted February 4, 2012 Share Posted February 4, 2012 Post the code. Link to comment https://forums.phpfreaks.com/topic/256386-dynamically-changing-image/#findComment-1314412 Share on other sites More sharing options...
oha055 Posted February 5, 2012 Author Share Posted February 5, 2012 Got it working! This is the code. I am new to PHP so feel free to comment if there are other, better ways of doing this private function showBlog() { $imageId = count($this->_filenames) - 1; if (isset($_GET['id'])) { $imageId = $_GET['id']; } ?> <center><img src="images/gallery/<?php echo $this->_filenames[$imageId]; ?>" /></center> <div id="navigation"> <div id="prev"> <a href="?id=<?php echo $imageId - 1; ?>">prev</a> </div> <div id="next"> <a href="?id=<?php echo $imageId + 1; ?>">next</a> </div> </div> <?php } Link to comment https://forums.phpfreaks.com/topic/256386-dynamically-changing-image/#findComment-1314611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.