asp网页页面中如何添加上一页 下一页代码

asp网页页面中如何添加上一页 下一页代码,第1张

代码如下:

<%

function thenext

newrs=server.CreateObject("adodb.recordset")

sql="select top 1 * from articles where id>"&a1&" order by id"

set newrs=conn.execute(sql)

if newrs.eof then

response.Write("没有了")

else

a2=newrs("id")

response.Write("<a href='view.asp?id="&a2&"'>下一篇</a>")

end if

end function

%>

'定义一个thehead函数来找出下一篇的ID,如果当前记录已经是最前面的一条记录,则输出文字“没有了”

<%

function thehead

headrs=server.CreateObject("adodb.recordset")

sql="select top 1 * from articles where id<"&a1&" order by id desc"

set headrs=conn.execute(sql)

if headrs.eof then

response.Write("没有了")

else

a0=headrs("id")

response.Write("<a href='view.asp?id="&a0&"'>上一篇</a>")

end if

end function

%>

'数据库连接文件

<!--#include file="conn.asp"-->

'取得传递过来的ID,显示文章标题作者和内容

<%

id=request("id")

sql="select * from articles where id="&id

set rs=conn.execute(sql)

%>

<%

boardid=rs("boardid")

%>

<title>文章系统-<% =rs("title") %></title>

<body leftmargin="0" topmargin="0">

<!--#include file="top.asp" -->

<%Do While Not rs.EOF%>

<table width="773" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="576" align="left"><table width="557" border="0" cellspacing="5" cellpadding="4" align="left"><tr><td colspan="2" align="center">

<span style="font-size:9pt color:#efefef"><%= rs("title") %><br><div align="right">

<span style="font-size:9pt color:#efefef">作者:<%= rs("author") %></span></div></span></td></tr><tr><td colspan="2" >

<span style="font-size:9pt color:#efefef">

<!--将数据库的资料取出,经过编码后输出,保持输入时的格式不变-->

<%= replace(server.HTMLEncode(rs("content")),chr(13),"<br>") %></span></td></tr><% a1=rs("id") %><tr><td width="269" align="right">

<!--调用前面定义的显示上一篇的函数-->

<% thehead %>

</td>

<td width="257" align="right">

<!--调用前面定义的显示下一篇的函数-->

<% thenext %></td></tr>

<% rs.MoveNext

Loop

%></table></td><td width="217" valign="top" align="left">相关文章:

'根据当前文章的栏目号,找出同一栏目的文章

<%sql="select * from articles where boardid="&boardid&""

set rs=conn.execute(sql)%>

<%Do While Not rs.EOF %>

<table width="207" border="0" cellspacing="2" cellpadding="2">

<tr>

<td height="20">

<a href="view.asp?id=<%=rs("id")%>">

<%= rs("title") %>

</a></td></tr></table>

<% rs.MoveNext%><%Loop%></td>

</tr>

</table>

<!--#include file="copyright.asp" -->

</body>

分类: 电脑/网络 >>程序设计 >>其他编程语言

问题描述:

我做了一个 往数据库添加数据的页 里面有验证码 这一项 但是当递交完页面后 再点 工具栏的"后退" 又回到递交页面 而 验证码没变 而且 还可以递交 我想 问问 怎么解决这个问题

能不能 点 后退后 验证码 自动变化

或者 让同一个 递交者 过5分钟后 再次递交

解析:

清除页面缓存的一些方法如下:

1、在Asp页面首部加入

Response.Buffer = True

Response.ExpiresAbsolute = Now() - 1

Response.Expires = 0

Response.CacheControl = "no-cache"

Response.AddHeader "Pragma", "No-Cache"

2、在HtML代码中加入

<HEAD>

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">

<META HTTP-EQUIV="Expires" CONTENT="0">

</HEAD>

3、在重新调用原页面的时候在给页面传一个参数

Href="****?random()"

1解释

当Buffer为True的时候,asp会将这个程序解释完毕后一起发送到客户端,当Buffer为False的

时候,asp会边解析边发送数据.

ExpiresAbsolute 属性指定缓存于浏览器中的页的到期日期和时间。在未到期之前,若用户

返回到该页,该缓存的页就显示。如果未指定时间,该主页在当天午夜到期。如果未指定日

期,则该主页在脚本运行当天的指定时间到期。

表示当前页面在客户端 CACHE 存储的时间,在指定时间内用户浏览此网页看到时

CACHE 里面的而不是最新的内容,超过了指定时间浏览器则重新从服务器上取最新的内容

,然后计时又重新开始。

CacheControl属性设置代理服务器是否可缓存ASP的输出。默认设置为不可存。

AddHeader 方法用指定的值添加 HTML 标题。该方法常常向响应添加新的 HTTP 标题。它并

不替代现有的同名标题。一旦标题被添加,将不能删除。

这是我自己的笔记 你看多点就明白了 只要是页网缓存问题 你取消了登陆 但网页缓存还是有保存数据的 所以你就得取消网页的缓存 所以就要用到上面的代码 具体都有解释了呀 不明吗?

只要把下面代码放到index.asp或者default.asp中,只要在首页代码顶部引用callCheck_Wap(),这个也是我的工程中使用的代码。用正则判断方便简洁。\x0d\x0a\x0d\x0aSubCheck_Wap()\x0d\x0adimMoblieUrl,reExp,MbStr\x0d\x0aMoblieUrl="/3g/index.asp"''手机网站路径\x0d\x0aSetreExp=NewRegExp\x0d\x0aMbStr="Android|iPhone|UC|WindowsPhone|webOS|BlackBerry|iPod"\x0d\x0areExp.pattern=".*("&MbStr&").*"\x0d\x0areExp.IgnoreCase=True\x0d\x0areExp.Global=True\x0d\x0aIfreExp.test(Request.ServerVariables("HTTP_USER_AGENT"))Then\x0d\x0aresponse.redirectMoblieUrl\x0d\x0aresponse.End\x0d\x0aEndIf\x0d\x0aEndSub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11527664.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存