php 实现文章上一页与下一页 代码
php 实现文章上一页与下一页 代码,这是我要写一个小作品时用到了,今天把它拿出来各各位分享一下下,记得以前我总想法不明白怎么实现文章上下一页的做法,后来在一个BBS看到了原来是判断当前ID然后order by 或asc就可以简单的实现了.
<?php function nextpage($fid, $tag, $bid) { if ('next' == $tag) { $sql = "select * from gx_news where id<$fid and menu_id='$bid' order by id desc"; } elseif ('prev' == $tag) { $sql = "select * from gx_news where id>$fid and menu_id='$bid' order by id asc"; } $result = mysql_query($sql); if (!mysql_num_rows($result)) { echo ('己经没有了!'); } else { $rs = mysql_fetch_array($result); echo "<a href=news_page.php?id=" . $rs[0] . ">" . $rs['new_title'] . "</a>"; } }
好了代码其实很容易的了我也不讲了只是给初学者看看文章上一页与下一页是怎么实现的喽.
本文地址:http://www.phprm.com/code/13577e8a125c21e7a32af25a27e670a4.html
转载随意,但请附上文章地址:-)