关于新闻的上一篇,下一篇

来源:互联网 发布:java 网盘系统源码 编辑:程序博客网 时间:2024/03/29 03:21
关于新闻的上一篇,下一篇


这个东东以前有朋友问过我,我写了个实例,大家可以做一参考
代码中做了注释,大家PP
问题由来主要是由于如果在数据库中删除了一篇文章后那么与它相连的其它文章判断有没有上一篇与下一篇文章就出现的问题,本文正是针对这一问题提出解决方案的。。。
完整的代码可以在此下载http://mlzboy.jahee.com/download/20040925.rar
<!--#include file="conn.asp" -->
<%
id为获得的欲显示该文章的参数值,此处为演示方便,在下面预先定义id=4
dim id
id=6
if not isnumeric(id) then
response.write "非法参数!"
response.end
end if
bigclass为大类,smallclass为小类,一般常见于二级分类的新闻系统
dim sql
sql="select * from eric where bigclass=校园新闻 and smallclass=校园娱乐 and id=" & id
call opendb()
set rs=conn.execute(sql)
if rs.eof then
判断库中是否有此文章
response.write "非法参数!"
response.end
else
str=rs(0) & "<br>"
str=str & rs(1) &"<br>"
str=str & "相关新闻:<br>------------------------------------<br>"
response.write str
call closers()
判断上面是否有与此文章所在类别的文章
sql="select * from eric where bigclass=校园新闻 and smallclass=校园娱乐 and id<" & id & " order by id desc"
set rs=conn.execute(sql)
if rs.eof then
response.write "上面已经没有文章了!<br>"
else
response.write "上一篇文章:" & rs(1) & "<br>"
end if
call closers()
判断下面是否有与此文章所在类别的文章
sql="select * from eric where bigclass=校园新闻 and smallclass=校园娱乐 and id>" & id
set rs=conn.execute(sql)
if rs.eof then
response.write "下面已经没有文章了!"
else
response.write "下一篇文章:" & rs(1) & "<br>"
end if
call closers()
call closedb()
end if
%> 
更新日期:2004-9-25 23:59:29 ,以前放在自己网站上的,转到这边来
原创粉丝点击