您的位置:首页 > 其它

文章上一篇 下一篇 功能

2012-12-29 21:22 211 查看
<?php
header('Content-Type: text/html; charset=utf-8');
mysql_connect('localhost','root','123456') or die(mysql_error());
mysql_select_db('cc');
mysql_query("set names 'utf8'");

$id =$_GET['id'];//是你当前文章的编

$sql ="select * from string_find where id>$id order by id asc limit 0,1";
//上一篇文章
$sql1 ="select * from string_find where id<$id order by id desc limit 0,1";
//下一篇文

$result = mysql_query($sql);
if( mysql_num_rows( $result )) {
$rs = mysql_fetch_array( $result );

echo "<a href='f.php?id=".$rs[0]."'>下一篇</a>".$rs[0];
} else {
echo "没有了";
}

$result1 = mysql_query( $sql1);
if( mysql_num_rows($result1))
{
$rs1 = mysql_fetch_array( $result1 );

echo "<a href='f.php?id=".$rs1[0]."'>上一篇</a>".$rs1[0];
} else {
echo "没有了";
}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐