记录分页

lonly 2001-07-23 01:47:24
我用的是 session 变量来进行记录分页的 但是刷新之后经常出错 有没有别的好的方法?
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyonet 2001-07-23
  • 打赏
  • 举报
回复
为什么用session
用<a href="csdn.net?page=9">dddddd</a>
不好吗?
wybm 2001-07-23
  • 打赏
  • 举报
回复
<% @ language="vbscript"%>
<%
option explicit
dim conn,sConnection,rs,sql,kinds_id,page,totalpages,count,myself,onepage,order,rs1,sql1
MySelf = Request.ServerVariables( "PATH_INFO" )
onepage=10
Set Conn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("../db/top.mdb") & ";" & _
"Persist Security Info=False"
Conn.Open(sConnection)
response.buffer=true
order=request.querystring("order")
if order="" then
order="pub_date"
end if
kinds_id=request("kinds_id")
if kinds_id="" then
kinds_id="all"
end if
set rs=server.createobject("adodb.recordset")
if kinds_id="all" then
if order="pub_date" then
sql="select * from T_news order by pub_date desc"
else
sql="select * from T_news order by clicktimes desc"
end if
else
if order="pub_date" then
sql="select * from T_news where kinds_id="&request("kinds_id")&" order by pub_date desc"
else
sql="select * from T_news where kinds_id="&request("kinds_id")&" order by clicktimes desc"
end if
end if
rs.open sql,conn,1,3
%>
<html>
<head>
<title>新闻中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script src="../openwin.js" language="javascript"></script>
<link rel="stylesheet" href="../css/style.css" type="text/css">
</head>
<body background="../manage/images/bg.gif">
<br>
<table width="95%" border="0" align="center" class="font_black">
<%if rs.eof and rs.bof then%>
<tr>
<td colspan="3">
<div align="center">
<%if kinds_id="" then%>
暂时还没有新闻
<%else%>
暂时还没有此类别新闻
<%end if%>
</div>
</td>
</tr>
<%else
rs.pagesize = onepage
page=clng(request("page"))
if page < 1 then page = 1
if page > rs.pagecount then page = rs.pagecount
rs.CacheSize =onepage
rs.MoveFirst
TotalPages = rs.PageCount
rs.AbsolutePage = Page
%>
<script language="javascript">
function mOvr(src,clrOver){
if (!src.contains(event.fromElement)) {
src.style.cursor = 'hand';
src.bgColor = clrOver;
}
}
function mOut(src,clrIn) {
if (!src.contains(event.toElement)) {
src.style.cursor = 'default';
src.bgColor = clrIn;
}
}
function mClk(src)
{
window.location.href="javascript:Source('view.asp?id=<%=rs("id")%>');" ;
}
</script>
<tr>
<td colspan="3">
<div align="center">新闻总数为: <font color=red><%=rs.pagecount%></font> 页 <font color=red><%=rs.RecordCount%></font>
条记录 当前为第 <font color=red><%=page%></font> 页 </div>
</td>
</tr>
<tr>
<td colspan="3">
<form name="form1" method="post" action="default.asp">
按类别查看新闻:
<select name="kinds_id">
<option value="all">所有新闻</option>
<%
set rs1=Server.CreateObject("ADODB.Recordset")
sql1="select * from T_newskinds"
rs1.open sql1,conn
do while not rs1.eof
%>
<option value="<%=rs1("id")%>"><%=rs1("kinds")%></option>
<% rs1.movenext
loop
rs1.close
set rs1=nothing
%>
</select>
<input type="image" border="0" name="imageField2" src="../images/view_button.gif" width="44" height="18">
</form>
</td>
</tr>
<tr>
<td width="77%">新闻主题</td>
<td width="7%">
<div align="center"><a href="default.asp?order=clicktimes&kinds_id=<%=request("kinds_id")%>">点击</a></div>
</td>
<td width="16%"><a href="default.asp?order=pub_date&kinds_id=<%=request("kinds_id")%>">发布日期</a></td>
</tr>
<%count=0
do while not rs.eof and count < onepage
%>
<tr bgColor=#f6f6f6 onclick="mClk();"
onmouseout="mOut(this,'#F6F6F6');"
onmouseover="mOvr(this,'#E7E9CF');">
<td width="77%" height="30"> <a href="javascript:Source('view.asp?id=<%=rs("id")%>');"><%=rs("title")%></a>
</td>
<td width="7%" height="30">
<div align="center"><%=rs("clicktimes")%></div>
</td>
<td width="16%" height="30"><%=datevalue(rs("pub_date"))%></td>
</tr>
<%
count=count+1
rs.movenext
loop%>
<tr>
<td colspan="3">
<div align="center">
<form action=<%=Myself%> method=post name="form" onSubmit="return check()" class="fontC9">
<%If Page <> 1 Then ' 如果不是位于第一页%>
<a href="<%=Myself%>?Page=1&kinds_id=<%=request("kinds_id")%>" target="main"><img src="../images/firs_button.gif" width="57" height="18" border="0"></a><a href="<%=Myself%>?Page=<%=(Page-1)%>&kinds_id=<%=request("kinds_id")%>" target="main"><img src="../images/prev_button.gif" width="57" height="18" border="0"></a>
<%End If
If Page <> rs.pagecount Then ' 如果不是位于最后一页
%>
<a href="<%=Myself%>?Page=<%=(Page+1)%>&kinds_id=<%=request("kinds_id")%>" target="main"><img src="../images/next_button.gif" width="57" height="18" border="0"></a>
<a href="<%=Myself%>?page=<%=rs.pagecount%>&kinds_id=<%=request("kinds_id")%>" target="main"><img src="../images/last_button.gif" width="57" height="18" border="0"></a>
<%End If
if rs.recordcount>10 then
%>
输入页次:
<input type=TEXT name=page size=3>
<input type="image" border="0" name="imageField" src="../images/view_button.gif" width="44" height="18">
页次:<font color="Red"><%=Page%>/<%=rs.pagecount%></font>
<input type="hidden" name="kinds" value="<%=request("kinds")%>">
</form>
<script language="JavaScript">
function check()
{
if (document.form.page.value=="")
{
window.alert ("请输入页码,页码范围1---<%=rs.PageCount%>! ");
document.form.page.focus();
return false;
}
return true;
}
</script>
</div>
<%
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</td>
</tr>
</table>
</body>
</html>


tripofdream 2001-07-23
  • 打赏
  • 举报
回复
除了userID等与安全有关的东西用session 保存外,其它的建议用<input type=hidden name=变量名 value=变量值>来保存

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧