All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
下一主题的实现_[PHP教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/10 6:51:22 Browse times: 348 Comment times: 0

下一主题的实现_[PHP教程]


Head photo

Go homepage
Upload pictures
Write articles

上一主题/下一主题的实现_[PHP教程] 第一种方法:定义通用函数
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>上一主题";}}


这里的 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 < id order by id desc limit 0,1";      break;    default:      sql = "select * from table where id = id";  }





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.