cgm225 Posted February 13, 2008 Share Posted February 13, 2008 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! Link to comment https://forums.phpfreaks.com/topic/90986-syntax-for-adding-value-to-variable-within-a-mysql-query/ Share on other sites More sharing options...
Daniel0 Posted February 13, 2008 Share Posted February 13, 2008 "SELECT * FROM images WHERE album = $album_id ORDER BY timestamp DESC LIMIT (" . $upper_limit + 1 . "), 1" ? Link to comment https://forums.phpfreaks.com/topic/90986-syntax-for-adding-value-to-variable-within-a-mysql-query/#findComment-466314 Share on other sites More sharing options...
cgm225 Posted February 13, 2008 Author Share Posted February 13, 2008 Thank you! Link to comment https://forums.phpfreaks.com/topic/90986-syntax-for-adding-value-to-variable-within-a-mysql-query/#findComment-466316 Share on other sites More sharing options...
cgm225 Posted February 13, 2008 Author Share Posted February 13, 2008 Where is the topic solved link? Link to comment https://forums.phpfreaks.com/topic/90986-syntax-for-adding-value-to-variable-within-a-mysql-query/#findComment-466319 Share on other sites More sharing options...
Daniel0 Posted February 13, 2008 Share Posted February 13, 2008 The modification has not been reinstalled after the upgrade from 1.1.1 to 1.1.4 of SMF. Link to comment https://forums.phpfreaks.com/topic/90986-syntax-for-adding-value-to-variable-within-a-mysql-query/#findComment-466323 Share on other sites More sharing options...
cgm225 Posted February 13, 2008 Author Share Posted February 13, 2008 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? Link to comment https://forums.phpfreaks.com/topic/90986-syntax-for-adding-value-to-variable-within-a-mysql-query/#findComment-466328 Share on other sites More sharing options...
Daniel0 Posted February 13, 2008 Share Posted February 13, 2008 Other than perhaps removing the parentheses after in the LIMIT There should be nothing wrong with the syntax. "SELECT * FROM images WHERE album = $album_id ORDER BY filename ASC LIMIT " . $image + 1 . ", 1" Link to comment https://forums.phpfreaks.com/topic/90986-syntax-for-adding-value-to-variable-within-a-mysql-query/#findComment-466331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.