<!--程序开始-->
'定义一个thenext函数来找出下一篇的ID,如果当前记录已经是最后一条记录,则输出文字“没有了”
<%
function thenext
newrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from article where id>"&id&" order by id"
set newrs=conn.execute(sql)
if newrs.eof then
response.Write("上一篇:")
response.Write("没有了")
else
a2=newrs("id")
response.Write("上一篇:")
response.Write"<a href='show_info.asp?id="&a2&"'>"
if len(newrs("title"))>18then
response.write(left(newrs("title"),18)&"...")
else
response.write(newrs("title"))
end if
response.Write "</a>"
end if
end function
%>
'定义一个thehead函数来找出下一篇的ID,如果当前记录已经是最前面的一条记录,则输出文字“没有了”
<%
function thehead
headrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from article where id<"&id&" order by id desc"
set headrs=conn.execute(sql)
if headrs.eof then
response.Write("下一篇:")
response.Write("没有了")
else
a0=headrs("id")
response.Write("下一篇:")
response.Write"<a href='show_info.asp?id="&a0&"'>"
if len(headrs("title"))>18 then
response.write(left(headrs("title"),18)&"...")
else
response.write(headrs("title"))
end if
response.Write "</a>"
end if
end function
%>
<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title></title>
<link href="../inc/style.css" rel="stylesheet" type="text/css" />
</head>
<body >
<!--#include file="top.ASP"-->
<%
dim rs,sql,id
id=request.QueryString("id")
id=checknum(id)
set rs=server.CreateObject("adodb.recordset")
sql="select * from article where id="&id&""
rs.open sql,conn,1
if rs.eof then
return_err"找不到指定记录",""
else
%>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" style="table-layout:fixed">
<tr>
<td height="10" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="Title"><div align="center"><%=rs("title")%></div></td>
</tr>
<tr>
<td height="57" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><%=rs("content")%></td>
</tr>
<tr>
<td height="20"></td>
</tr>
<tr>
<td align="center"><% thehead %> <% thenext %> </td>
</tr>
</table> </td>
</tr>
</table>
<%
end if
rs.close
set rs=nothing
closeconn
%>
</DIV>
<!--#include file="bottom.ASP"-->
</body>
</html>
更多的asp程序显示上一篇下一篇的代码请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2008-11-12