Jump to content

Selecting the next existing record...


Jabop

Recommended Posts

I have a site where users view images. Simple.

My prior method to displaying which image was using the record ID to get the image info

 

Example:

/images.html?view=3

 

<?php
$DB->query("SELECT ID,Title FROM images WHERE ID<'".$_REQUEST['view']."' ORDER BY ID DESC LIMIT 1");
list($NextID,$NextTitle)=$DB->next_record();
?>

 

This would successfully select the next image in the database, in relation to the current Image ID.

 

However, I have now changed the method that users view images

 

Example:

/images/image_title

 

<?php
$DB->query("SELECT ID,Title,FileName FROM images WHERE FileName<'".$_REQUEST['view']."' ORDER BY ID DESC LIMIT 1");
list($NextID,$NextTitle,$FileName)=$DB->next_record();
?>

 

This fails.

 

The problem:

Some rows are missing. Example 1-10 exist, 11, 12, 13 are missing, 14 exists, and so on. How can I select the next EXISTING record, based off of the FileName?

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.