adam291086 Posted October 3, 2007 Share Posted October 3, 2007 I have a page that displays a full picture once the thumbnail has been clicked on. The php then takens the ID number of that thumbnail pic and finds the full image and displays it. I want to add a NEXT button that will automatically move to the next picture within the database without having to go back a back and view all the thumbnails. How do i do this. Below is the code that displays the big picture <?php include("config.php"); if( !$_GET['photo_id'] ){ $msg .= "No photo selected! Please <a href=\"gallery.php\">choose an album</a> you would like to view."; // Display error message displayPage($msg); die(); } $con; $sql = "SELECT photo_title, photo_location FROM photos WHERE photo_id = " . addslashes($_GET['photo_id']); $result = @mysql_query($sql) or die("Error retrieving record: " . mysql_error()); while($row = @mysql_fetch_array($result)){ $photo_title = $row['photo_title']; $photo_loc = $row['photo_location']; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Gallery - <?php echo($photo_title); ?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td>Gallery - <?php echo($photo_title); ?></td> </tr> </table> <table width="60%" border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td> <img src="<?php echo($photo_loc); ?>" /> </td> </tr> </table> <table width="60%" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td><a href="gallery.php">View Gallery</a></td> </tr> </table> </td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted October 3, 2007 Share Posted October 3, 2007 I'd assume this is using get to pass the small images, I didn't take the time to read your code. any way if it is just make a link to the current image_id + 1 or -1 on the page and you are all set. However you will want to first run a query to verify that the next image or last is real. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 3, 2007 Author Share Posted October 3, 2007 Thanks, i'll give it a try Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 3, 2007 Author Share Posted October 3, 2007 I have the next button working, by adding 1 to the photo Id each time the next button is clicked. But when i get to an ID number where there isn't a picture i want a message to display '' end of album'' How do i do this? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted October 3, 2007 Share Posted October 3, 2007 like I said you need to query for the max ID number and then run a test on each page saying if next would equal make show error or make next = to start of the gally Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.