Jump to content

"next-back" photo change


web_master

Recommended Posts

hi,

 

I have 2 tables

 

1 Table is

gallery_id

gallery_name

 

2 Table is

photo_id

photo_gallery_id

 

(photo_gallery_id = gallery_id)

 

I make a list of photos (photo_id)

 

$query_return = mysql_query("SELECT * FROM `photo` WHERE `photo_gallery_id` = ' " . $_GET['gallery_id'] . " ' ORDER BY `photo_id`");

 

 

than I "magnify" one picture like

 

while($request = mysql_fetch_array($query_return)) {

 

<a href="photo_magnify.php?photo_id=" . $request['photo_id'] . "&gallery_id=" . $request['photo_gallery_id'] . "">magnify</a>

 

}

 

 

in "photo_magnify.php" want to make a "BACK" and "NEXT" button to see next or preview photo but only photos which are in given photo gallery.

 

If no more pict up or down - dont see the BACK or NEXT button...

 

I hope it is understandable...

 

Thanx in advance

 

 

 

 

Link to comment
Share on other sites

Or just use some if statements. Pagination I think is more for showing ALL possible pages. If he wants ONLY back/next buttons, I would do this:

 

- Create a variable to contain how many pictures you've got in the gallery.

- Use if statements to place the buttons with links to id-1 or id+1 if you aren't at the beginning or end.

 

So like (very basic):

<?php
$numpics = mysql_num_rows($result);
while() {
	$id = $row["id"];
	$nextid = $id+1;
	$previd = $id-1;
	if ($id != 1 && $id != $numpics) {
		echo "<a href=\"showpic.php?id=$previd\">back</a>";
		echo "<a href=\"showpic.php?id=$nextid\">next</a>";
		echo "<img src=\"img/$id.jpg\" />";
	} else if ($id != 1) {
		echo "<a href=\"showpic.php?id=$previd\">back</a>";
		echo "<img src=\"img/$id.jpg\" />";
	} else if($id != $numpics) {
		echo "<a href=\"showpic.php?id=$nextid\">next</a>";
		echo "<img src=\"img/$id.jpg\" />";
	}
}
?>

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.