Jump to content

Checking for MySQL entry/row before and after limits


cgm225

Recommended Posts

Currently I grab entries/rows from a mysql database for my gallery based on the following:

 

    $query = "SELECT * FROM images WHERE album = $album_id ORDER BY timestamp DESC LIMIT $lower_limit , $upper_limit"; //the upper and lower limit variables are numeric integers in value, for example: 30, 60
    $image_results = mysql_query($query);

 

My question is, what is the easiest way to check, separately, if there exists an entry/row right before the lower limit, and if there exists an entry/row right after the upper limit?

 

Thank you for your help.

Sorry, let me clarify.. if I use the query I outlined above, and limit the returned rows such that only the 30th to 60th rows are returned (limits I set dynamically using the $lower_limit and $upper_limit php variables), what is the best way to check for the existence of rows immediately adjacent to the upper and lower limits (so, in this example, is there a 29th and 61st row?).

 

I am checking for these rows to determine if a previous/next button is to be included in my pagination.

 

Thanks again!

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.