第一种方法:定义通用函数
function shownext(){
global $thisid;
$query="select * from TABLE_NAME where id>$thisid order by id limit 1";
$result=mysql_query($query);
if($result=0){
echo "已经是第一个主题了";
}else{
if($row=mysql_fetch_array($result))
$nextid=$row["id"];
echo "下一主题";
}
}
function showpre(){
global $thisid;
$query="select * from TABLE_NAME where id
$result=mysql_query($query);
if($result=0){
echo "已经是最后一个主题了";
}else{
if($row=mysql_fetch_array($result))
$preid=row["id"];
echo "上一主题";
}
}
这里的 $thisid 为当前主题的id
第二种方法:假设有一个主题链接为 (当前id为100)
detail.php?id=100&action=pre
或者
detail.php?id=100&action=next
然后在主题显示页面detail.php取记录时使用如下条件语句
switch($acttion) {
case 'next':
$sql = "select * from table where id > $id limit 0,1";
break;
case 'prev':
$sql = "select * from table where id
break;
default:
$sql = "select * from table where id = $id";
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号