Jump to content

Recommended Posts

I have a page that displays and image based on the id specified on the URL. What i'd like to do is add a previous and next link from that id. I've created the code below, which was working fine. BUT the problem occurs when a row is deleted, it assumes there's no next record. For example, if the DB has records 1,2,3,6,7 and the user is viewing image 2, then the next button will show image 3, but then it will disappear because 4 is NULL. I need it to go to 6 from 3. How can I take the next id rather then specifying $id+1?

 

  <?/*
  	$next = $id+1;
$sql3 = mysql_query("SELECT * FROM images WHERE id='$next'");
$row3 = mysql_fetch_array($sql3);
$date3 = $row2[date];
$tag3 = $row2[tags];	
	if ($row3!=NULL){
		echo "<a href='/pic.php?d=".$date3."&id=".$next."'><img src='/images/arrowright.gif' border='0' alt='".$tag3."'></a>";	
	}
  */?>  

Link to comment
https://forums.phpfreaks.com/topic/87315-solved-previous-and-next/
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.