web_master Posted July 6, 2007 Share Posted July 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 You want to google Pagination or look at the tutorials section of PHPFreaks for Pagination. That is what you want. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted July 6, 2007 Share Posted July 6, 2007 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\" />"; } } ?> 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.