Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // OPEN THE CONNECTION
- //
- include ("../var/db_connect.php");
- // CREATE AN ARRAY WITH ALL THE IMAGE ID'S IN THE GALLERY
- //
- $query = ("SELECT id FROM images WHERE gallery_id=(SELECT gallery_id FROM images WHERE id='".$_REQUEST['id']."') ORDER BY id DESC");
- $result = mysql_query($query);
- $images_in_gallery = array();
- while ($row = mysql_fetch_array($result))
- {
- array_push($images_in_gallery, $row['id']);
- }
- // ASSIGN TEXT FOR THE LINKS, THIS CAN BE CHANGED TO IMAGES
- //
- $next_text = 'Older';
- $prev_text = 'Newer';
- // CREATE THE LINK
- //
- $next_link = "<a href=\"?id=".$images_in_gallery[array_search($_REQUEST['id'], $images_in_gallery)+1]."\">$next_text</a>";
- $prev_link = "<a href=\"?id=".$images_in_gallery[array_search($_REQUEST['id'], $images_in_gallery)-1]."\">$prev_text</a>";
- // DISABLE HYPERLINKING ON FIRST AND LAST IMAGES IN THE GALLERY FOR APPROPRIATE LINKS
- //
- if ($next_link == "<a href=\"?id=\">$next_text</a>")
- $next_link = "$next_text";
- if ($prev_link == "<a href=\"?id=\">$prev_text</a>")
- $prev_link = "$prev_text";
- // GET THE IMAGE CAPTION AND ALT TAG
- //
- $query = ("SELECT caption FROM images WHERE id='".$_REQUEST['id']."'");
- $result = mysql_query($query);
- $row = mysql_fetch_array($result);
- // CLOSE THE CONNECTION
- //
- mysql_close($con);
- ?>
- <!-- Show some ouput for testing -->
- <br /> <br />
- <?php echo $prev_link; ?>
- <?php echo $next_link; ?>
- <br /> <br />
- <img src="image.php?id=<?php echo $_REQUEST['id']; ?>" alt="<?php echo $row['caption']; ?>" />
- <p><?php echo $row['caption']; ?></p>
- <!-- --------------------------- -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement