代码
'******************************************************
'Depiction:ShowHead
'Param:CiassID 类别ID号
' Article_id 当前文章ID号
'Returns:返回上一篇文章的链接
'******************************************************
Sub ShowHead(ClassID,Article_id)
Sql = "Select top 1 * from Fzarticle Where Article_id > "& Article_ID &" And ClassID = "& ClassID &" order by Article_ID desc"
Set HRs = Conn.Execute(Sql)
If Not HRs.Eof Then
Response.Write "
"&HRs("title")&""
Else
Response.Write "已经是最前一篇了"
End If
HRs.Close
Set HRs = Nothing
End Sub
'******************************************************
'Depiction:ShowNext
'Param:CiassID 类别ID号
' Article_id 当前文章ID号
'Returns:返回下一篇文章的链接
'******************************************************
Sub ShowNext(ClassID,Article_id)
Sql = "Select top 1 * from Fzarticle Where Article_id < "& Article_ID &" And ClassID = "& ClassID &" order by Article_ID desc"
Set HRs = Conn.Execute(Sql)
If Not HRs.Eof Then
Response.Write "
"&HRs("title")&""
Else
Response.Write "已经是最后一篇了"
End If
HRs.Close
Set HRs = Nothing
End Sub
===================================================================================
原版:
<%
pid1=rs("id")
function Getpre
sql="select top 1 * from 数据表 where id>"&pid1&" order by id"
set rs=conn.execute(sql)
if rs.eof or rs.bof then
response.Write("没有新闻了")
else
pid2=rs("id")
response.Write("
"&rs("title")&"")
end if
end function
function Getnext
sql="select top 1 * from 数据表 where id<"&pid1&" order by id desc"
set rs=conn.execute(sql)
if rs.eof then
response.Write("没有新闻了")
else
pid3=rs("id")
response.Write("
"&rs("title")&"")
end if
end function
%>
调用方法:
上一篇:<% getpre %>
下一篇:<% getnext %>
改进版:
<%
pid1=request("id")
rs.open "select top 1 * from info where id>"&pid1&" order by id",conn,1,1
if rs.eof or rs.bof then
getpre="·没有文章了!"
else
pid2=request("id")
getpre=getpre&"
"&rs("title")&""
end if
rs.close
pid3=request("id")
rs.open "select top 1 * from info where id<"&pid3&" order by id desc",conn,1,1
if rs.eof or rs.bof then
getnext="·没有文章了!"
else
pid4=request("id")
getnext=getnext&"
"&rs("title")&""
end if
rs.close
pencat=replace(pencat,"[GETPRE]",getpre)
pencat=replace(pencat,"[GETNEXT]",getnext)
%>
阅读(362) | 评论(0) | 转发(0) |