PHP实现上一篇、下一篇的代码_PHP教程
时间:2021-07-01 10:21:17
帮助过:5人阅读
代码:
-
-
- $sql_former = "select * from article where id<$id order by id desc ";
- $sql_later = "select * from article where id>$id ";
- $queryset_former = mysql_query($sql_former);
- if(mysql_num_rows($queryset_former)){
- $result = mysql_fetch_array($queryset_former);
- echo "上一篇 ". $result[title]."
";
- } else {echo "上一篇 没有了
";}
- // www.jbxue.com
- $queryset_later = mysql_query($sql_later);
- if(mysql_num_rows($queryset_later)){
- $result = mysql_fetch_array($queryset_later);
- echo "下一篇 ". $result['title']."
";
- } else {echo "下一篇 没有了
";}
- ?>
http://www.bkjia.com/PHPjc/729837.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/729837.htmlTechArticle代码: ?php //----显示上一篇、下一篇文章代码START---- $sql_former = "select*fromarticlewhereid$idorderbyiddesc" ; //上一篇文章sql语句。注意是倒序,因为...