Home > php教程 > php手册 > body text

PHP经典面试题:实现上一篇和下一篇文章

WBOY
Release: 2016-06-07 11:37:30
Original
1434 people have browsed it

我们在面试的时候常常会遇到,用sql写出查询上一篇和下一篇文章的ID。今天我们就分享下最简单的上一篇和下一篇文章的查询代码。
PHP经典面试题:实现上一篇和下一篇文章
获取当前浏览文章id$id = isset($_GET['id']) > 0 ? intval($_GET['id']) : "";下一篇文章$query = mysql_query("SELECT id,title FROM article WHERE id>'$id' ORDER BY id ASC LIMIT 1"); <br> $next = mysql_fetch_array($query);上一篇文章$query = mysql_query("SELECT id,title FROM article WHERE id  $prev = mysql_fetch_array($query);页面显示上一篇和下一篇文章标题和链接<div> <br>     <div> <br>         <a>"><?php echo $next[&#039;title&#039;]; ?></a>         <br>     </div> <br>     <div> <br>         <a>"><?php echo $prev[&#039;title&#039;]; ?></a>  <br>     </div> <br> </div>上一篇和下一篇文章演示:http://www.sucaihuo.com/php/436.html

附件 PHP+Mysql实现上一篇和下一篇文章.zip ( 5.9 KB 下载:31 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!