Welcome Guest, Not a member yet? Register   Sign In
How can I get the current post's index by slug?
#2

(This post was last modified: 02-08-2021, 09:42 AM by CINewb.)

What determines the order of the posts? Is it the ID, or the date? Why not create a function where you pass in the ID or the date of the current post, to get the next one. The SQL would be something like:

SELECT * FROM `posts` WHERE `ID` > ? ORDER BY `ID` ASC LIMIT 1

This will get you the next post in the list by ID. If your posts are ordered by date rather than ID, it would be:

SELECT * FROM `posts` WHERE `date` > ? ORDER BY `date` ASC LIMIT 1
Reply


Messages In This Thread
RE: How can I get the current post's index by slug? - by CINewb - 02-08-2021, 09:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB