MySQL / PHP:查找上一行/下一行

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 viewing 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>