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
https://forums.phpfreaks.com/topic/109221-selecting-the-next-existing-record/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.