Toshiba23 Posted August 23, 2007 Share Posted August 23, 2007 Ok... here's a question. On forums like phpBB, vBulletin, invision, (and probably this one), when viewing a topic... there's links at the top of it that give you an option to go to "The next topic" in that forum. Well, the topic your own might have an id of 105, and the next one in the forum might be 109, so my question is: How do I find the next, and previous items in a mysql query, when I format my query such as: $query = "SELECT * FROM photos WHERE photo_id='105'"; $result = mysql_query($query); I want to be able to find the next and previous photo_id in the same album... Some help please? Quote Link to comment https://forums.phpfreaks.com/topic/66381-next-previous-results/ Share on other sites More sharing options...
phpSensei Posted August 23, 2007 Share Posted August 23, 2007 Its Called Pagination. Here is a good tutorial on it...http://php.about.com/od/phpwithmysql/ss/php_pagination.htm edit: Or why don't you search this website for a tutorial. On the main page that is.... Quote Link to comment https://forums.phpfreaks.com/topic/66381-next-previous-results/#findComment-332199 Share on other sites More sharing options...
Toshiba23 Posted August 23, 2007 Author Share Posted August 23, 2007 Its Called Pagination. Here is a good tutorial on it...http://php.about.com/od/phpwithmysql/ss/php_pagination.htm edit: Or why don't you search this website for a tutorial. On the main page that is.... I'm well aware of how to program paging... but how do you make a "next photo" while displaying the current information of one ... ? Quote Link to comment https://forums.phpfreaks.com/topic/66381-next-previous-results/#findComment-332200 Share on other sites More sharing options...
lemmin Posted August 23, 2007 Share Posted August 23, 2007 You will have to know how the topics are organized. The reason the numbres jump is probably because 106, for example, might be in a different section (This is how mine works, at least.) When you make your query, you need to check the section id against the current one, something like: "SELECT topicid FROM topics WHERE topicid > $currenttopicid AND sectionid = $currentsectionid ORDER BY topicid LIMIT 1" Something like that should do it. Quote Link to comment https://forums.phpfreaks.com/topic/66381-next-previous-results/#findComment-332202 Share on other sites More sharing options...
Toshiba23 Posted August 23, 2007 Author Share Posted August 23, 2007 Yeah, I just looked at phpBB's version, just was a brain fart on my part I guess, thanks Quote Link to comment https://forums.phpfreaks.com/topic/66381-next-previous-results/#findComment-332211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.