Jump to content

Syntax for adding value to variable within a MySQL query...


cgm225

Recommended Posts

I have the following MySQL query::

 

"SELECT * FROM images WHERE album = $album_id ORDER BY timestamp DESC LIMIT $upper_limit, 1"

 

but if I want to query it with the limit value of ($upper_limit + 1), what is the syntax for querying with that resulting sum within the query line without having to make a new variable with the sum outside the line beforehand?

 

i.e., something like this is what I am going for (though I know this syntax is wrong)

"SELECT * FROM images WHERE album = $album_id ORDER BY timestamp DESC LIMIT ($upper_limit + 1), 1"

 

Thank you all in advance!

Sorry, that syntax does not seem to be working.  I have::

 


    if ((mysql_num_rows(mysql_query("SELECT * FROM images WHERE album = $album_id ORDER BY filename ASC LIMIT (" . $image + 1 . "), 1"))) > 0) { 
        echo "\t\t\t\t\t\t<a href='http://www.example.com/photos/$album/$nextpage/" . ($image + 1) . "'>Next</a>\n";
    }

 

Any ideas?

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.