marhoons Posted May 4, 2008 Share Posted May 4, 2008 Dear all, good day to you.. it is any way to know the Next & previous ID after the current record? i draw a simple scenario: please advice and guide me. Thanks, Yours M a r h o o n Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/ Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 This subject is known as pagination. Using mysql you use 'limit' Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/#findComment-532847 Share on other sites More sharing options...
marhoons Posted May 4, 2008 Author Share Posted May 4, 2008 no my dear i dont meant pagination.... see: I mean if i display the article has id: 8 the next article should be 4 as my draw figure. and the previous should be 5. again i did not mean pagination... thanks for fast reply. Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/#findComment-532854 Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 Its surely the same thing, just that your using id's instead of pages? Your just using a different search, producing a similar list ordered by id, which is certain terms is identical... If i'm still off track can you re-explain please? Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/#findComment-532858 Share on other sites More sharing options...
marhoons Posted May 4, 2008 Author Share Posted May 4, 2008 thanks again.... come with me... i display article has Id 8 by this syntax: $sql= mysql_query("select * from articles where id='8' "); $row= mysql_featch_array($sql); . . . . . . . in this case how i know the next & previous article (recored)? Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/#findComment-532862 Share on other sites More sharing options...
LemonInflux Posted May 4, 2008 Share Posted May 4, 2008 If I understand you correctly, why not timestamp the articles, then order them by that? If you ID's aren't in logical order, they're probably not the best thing to use. Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/#findComment-532869 Share on other sites More sharing options...
marhoons Posted May 4, 2008 Author Share Posted May 4, 2008 my primary indexes & display the article by id .. i'm asking if there's any specail function to identfy the next & prv. pointer! thanks again and hope to hear good way... already this fourms using whats i want to do it! Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/#findComment-532876 Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 What are you using to order by? Using limit gets the required element without ever actually caring what the previous or next element are! Link to comment https://forums.phpfreaks.com/topic/104090-how-mysql-next-previous-record/#findComment-532887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.