wrathican Posted May 19, 2008 Share Posted May 19, 2008 hey thanks for looking. ive created a custom image gallery and there are 3 stages. 1. view list of albums 2. view list of images within selected album 3. view selected image from select album with links to the next and previous image in the list the problem is i have no idea how to implement the next/prev links im using the $_GET method to determine which image should be displayed for stage 3. so it looks something like this: <?php $img = $_GET['img']; $query = "select * from image_table where image_id='".$img."'"; $result = mysql_query($query); ?> i thought about using a while loop to loop through each entry that belongs to the selected album and create variables numbered accordingly so it'd be something like: <?php $i = 1; while ($row = mysql_fetch_array($result) { //delclare vars $var . $i = $row['entry']; } ?> Would something like this be right? or am i going about this all wrong? Link to comment https://forums.phpfreaks.com/topic/106308-custom-image-gallery-nextprev-buttons/ Share on other sites More sharing options...
MatthewJ Posted May 19, 2008 Share Posted May 19, 2008 Most pagination I have seen is generally done using the LIMIT clause of the query. for instance $currImage = 0; SELECT * FROM table LIMIT $currImage,1 would get the first pic, then increment the $currImage variable when they press the "next" button, and it will set limit to 1,1 and so on. Then you can decrement when they press the previous button. HOpe that helps get you started, Matt Link to comment https://forums.phpfreaks.com/topic/106308-custom-image-gallery-nextprev-buttons/#findComment-544962 Share on other sites More sharing options...
wrathican Posted May 26, 2008 Author Share Posted May 26, 2008 well, ive looked at pagination but it cant see how to implement this to suit my needs. i couldnt use the LIMIT clause because i only want to display one image. so i need to find out the ID of the next image in the album and the previous image the album. these may not be in order so the current image ID could be 34 and the next image could be 55 that belongs to that album and previous image could be 6. i kinda figure it would happen something like this: GET current image id from url GET current album id from url QUERY the database an select all the images that belong to the album do some sort of while loop to figure out the next an previous image id's anyone able to help? Link to comment https://forums.phpfreaks.com/topic/106308-custom-image-gallery-nextprev-buttons/#findComment-550399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.