Jump to content

[SOLVED] next button


adam291086

Recommended Posts

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.