显示上一篇下一篇的代码

来源:互联网 发布:c语言写游戏辅助 编辑:程序博客网 时间:2024/04/28 06:58

  <!--程序开始-->
'定义一个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="inc/dbconn.asp"-->
<!--#include file="inc/ubbcode.asp"-->
<!--#include file="inc/Function.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">&nbsp;</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 %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%  thenext %> </td>
      </tr>
                      </table> </td>
                  </tr>
</table>
<%
end if
rs.close
set rs=nothing
closeconn
%>
</DIV>
<map name="Map" id="Map"><area shape="rect" coords="675,5,765,30" href="join.asp" title="加盟金牌会员指南"/>
</map>
<!--#include file="bottom.ASP"-->
</body>
</html>

 

 

原创粉丝点击