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.

Link to comment
Share on other sites

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!

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.