开发者

MySQL/PHP: Find previous / next row

I'm making a forum for skills.

I want to print a previous and/or next link on the thread page. So if theres a thread with a larger and/or lesser number than current, print it in lionk. And also i wanna limited only threads from the same forum as the thread im vi开发者_开发问答ewing is located in.

Basically likes this forum:

http://forum.tibia.com/forum/?action=thread&threadid=3099663

Look under the Post Reply button.

Thanks alot


SELECT MAX(id) as prev_thread_id
  FROM threads
 WHERE id < <current_thread_id>
   AND forumid = <current_forum_id>

and

SELECT MIN(id) as next_thread_id
  FROM threads
 WHERE id > <current_thread_id>
   AND forumid = <current_forum_id>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜