sql2="select * from article_info where id=120"
set rs2=conn.execute(sql2)
n=getThePage(rs2("id"),"3","next",rs2("inDate"))
response.Write("下一篇文章:"&n&"<br>")
p=getThePage(rs2("id"),"3","pre",rs2("inDate"))
response.Write("上一篇文章:"&p&"<br>")
function getThePage(id,classid,order,inDate)
dim rs,sql,pre,re
sql="select top 1 * from article_info where classid="&classid&" and audit=1 and publish=1"
if order="next" then
sql=sql&" and datediff(’d’,’"&inDate&"’,inDate)>0 order by inDate asc"
else
sql=sql&" and datediff(’d’,’"&inDate&"’,inDate)<0 order by inDate desc"
end if
set rs=conn.execute(sql)
if not rs.eof then
re="<a href=’" & rs("id") & ".shtml" &"’>" & rs("title") & "</a>"
getThePage=re
else
getThePage="没有了"
end if
rs.close
set rs=nothing
end function
rs2.close
set rs2=nothing
注:表名是article_info,当前新闻内容的id为120
sql=sql&" and datediff(’d’,’"&inDate&"’,inDate)>0 order by inDate asc"中第二个inDate是数据库中相应的字段名,上一篇文章和下一篇文章是根据当前新闻内容发布的时间作为依据的。
下一篇文章:大与当前新闻发布时间的所有新闻中发布时间最小的那篇文章
上一篇文章:小与当前新闻发布时间的所有新闻中发布时间最大的那篇文章
set rs2=conn.execute(sql2)
n=getThePage(rs2("id"),"3","next",rs2("inDate"))
response.Write("下一篇文章:"&n&"<br>")
p=getThePage(rs2("id"),"3","pre",rs2("inDate"))
response.Write("上一篇文章:"&p&"<br>")
function getThePage(id,classid,order,inDate)
dim rs,sql,pre,re
sql="select top 1 * from article_info where classid="&classid&" and audit=1 and publish=1"
if order="next" then
sql=sql&" and datediff(’d’,’"&inDate&"’,inDate)>0 order by inDate asc"
else
sql=sql&" and datediff(’d’,’"&inDate&"’,inDate)<0 order by inDate desc"
end if
set rs=conn.execute(sql)
if not rs.eof then
re="<a href=’" & rs("id") & ".shtml" &"’>" & rs("title") & "</a>"
getThePage=re
else
getThePage="没有了"
end if
rs.close
set rs=nothing
end function
rs2.close
set rs2=nothing
注:表名是article_info,当前新闻内容的id为120
sql=sql&" and datediff(’d’,’"&inDate&"’,inDate)>0 order by inDate asc"中第二个inDate是数据库中相应的字段名,上一篇文章和下一篇文章是根据当前新闻内容发布的时间作为依据的。
下一篇文章:大与当前新闻发布时间的所有新闻中发布时间最小的那篇文章
上一篇文章:小与当前新闻发布时间的所有新闻中发布时间最大的那篇文章
热门信息
阅读 (126)
1 ASP+AJAX实现分页效果[Z]阅读 (125)
2 ASP 微信公共平台接口实现代码阅读 (118)
3 [jQuery1.9]Cannot read property ‘msie’ of undefined错误的解决方法阅读 (118)
4 提高IIS+ASP网站安全性的方法阅读 (118)
5 用ASP删除文件