当前文章的id为 $article_id,当前文章对应分类的id是$cat_id,那么上一篇就应该是:

SELECT max(article_id) FROM article WHERE article_id < $article_id AND cat_id=$cat_id; 
//执行这段sql语句后得到 $max_id,然后 
SELECT article_id, title FROM article WHERE article_id = $max_id; 
//简化一下,转为子查询即:
SELECT article_id, title FROM article WHERE article_id = (SELECT max(article_id) FROM article WHERE article_id < $article_id AND cat_id=$cat_id);

下一篇为:

SELECT min(article_id) FROM article WHERE article_id > $article_id AND cat_id=$cat_id;
//执行这段sql语句后得到 $min_id,然后
SELECT article_id, title FROM article WHERE article_id = $min_id;
//简化一下,转为子查询即:
SELECT article_id, title FROM article WHERE article_id = (SELECT min(article_id) FROM article WHERE article_id > $article_id AND cat_id=$cat_id);