一个翻页的小问题,请高手指教。

zyy1971 2003-09-25 05:00:53

我用一个表单调用下列程序, 能够显示出查询结果的第一页,但点“下一页”时没有反应。

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件搜索</title>
</head>

<body>
<div align="left">

<html>
<title>分页技术</title>
<head>
<%
const MaxPerPage=10
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim page
%>
</head>
<body bgcolor=Thistle>
<!--#INCLUDE file="ADOVBS.inc"-->
<% '建立数据库的连接
word=trim(request("word"))

dim mycon,con
Set con=Server.CreateObject("ADODB.Connection")
mycon= "DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("/study/search.mdb")
con.open mycon


%>
<!--'建立CONNECTION对象并打开数据库
'创建Recordset对象的例程,打开Recordset对象传递SQL串以及所有的连接信息 -->
<% set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT * FRoM redsearch where id or keyword or title like '%"&word&"%'",MyCon,1,3

if not(rs.eof and rs.bof) then
rs.movefirst
end if
%>


<%

rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1
page=1

If trim(Request("word"))<>"" then
CurrentPage= page
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'> 没有符合条件的记录!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if

dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
</FONT></FONT></P>
<%rs.movefirst%>
<P>第 <%=currentpage%> 页,共 <%=n%> 页 符合查找条件的共<%=rs.recordcount%> 条纪录

</P>

<TABLE border=1 align=center>
<tr>
<TD><div align="center"><B>文件编号</B></div></TD>
<TD><div align="center"><B>题 目</B></div></TD>
<TD><div align="center"><B>关键字</B></div></TD>

<%
for i= 0 to howmanyfields%>
<%
next
i=0
do while not rs.eof and i<maxperpage%>
<tr align=middle>
<%for j=0 to howmanyfields-1%>

<td>  
<div align="left"> <a href="http://server/study/<% =rs("url") %>"> <%=rs(j)%> </a></div></td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</TABLE>
<% k=currentPage
if k<>1 then
response.write "<b>"+"<a href='search.asp?page=1,word="+chr(34)+word+chr(34)+"'>首页</a></b> "
response.write "<b>"+"<a href='search.asp?page="+cstr(k-1)+",word="+chr(34)+word+chr(34)+"'>上一页</a></b> "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "<b>"+"<a href='search.asp?page="+cstr(k+1)+",word="+chr(34)+word+chr(34)+"'>下一页</a></b> "
response.write "<b>"+"<a href='search.asp?page="+cstr(n)+",word="+chr(34)+word+chr(34)+"'>尾页</a></b> "
else
Response.Write "[下一页] [尾页]"
end if
Response.Write rs.recordcount
%>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>
...全文
37 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xyp730000 2003-09-27
  • 打赏
  • 举报
回复
不好意思,发错地方那!!!!!!!!
xyp730000 2003-09-27
  • 打赏
  • 举报
回复
zhlym (明) 你在QQ上是叫“梅子情缘”吗?
xyp730000 2003-09-25
  • 打赏
  • 举报
回复
给你一个分页程序:
<%
set rs=server.createobject("adodb.recordset")
sql="select * from wjname where wjjia_id like "&session("wjjia_id_1")&" order by datatime desc"

rs.open sql,conn,1,1
if rs.eof and rs.bof then
str="没有!"
end if
if str="" then
rs.PageSize=15
pages=rs.pagecount
records=rs.recordcount
page=request("page")
if page="" or page<1 then page=1
page=cint(page)
if page>pages then page=pages
rs.absolutepage=page
else
page=1
records=0
pages=1
end if
%>


共有 <%=Records%> 个文件 页次<%=page%>/<%=pages%> 当前第<%if page<>1 then%>
<a href="main.asp?id=<%=session("wjjia_id_1")%>&page=1" title="第1页">[<u>1</u>]</a> 
<%else%>
<%if pages=1 then%>
<font color="red">1</font>
<%else%>
<font color="red">1 </font>
<%end if%>
<%end if%>
<%if pages> 1 then
MaxShowPage=5
s = page - MaxShowPage
if s> pages -MaxShowPage*2 + 1 then s= pages -MaxShowPage*2 + 1
if s<1 then s = 1 end if
e = page + MaxShowPage
if e< MaxShowPage*2 + 1 then e= MaxShowPage*2 + 1
if e> pages-1 then e= pages - 1
if s>1 then response.write "…" end if
for l= s+1 to e%>
<%if page<>l then%>
<a href="main.asp?id=<%=session("wjjia_id_1")%>&page=<%=l%>" title="第<%=l%>页">[<u><%=l%></u>]</a> 
<%else%>
<font color="red"><%=l%></font> 
<%end if%>
<%next%><%if e < pages-1 then%>… <%end if %><a <%if page=pages then%> style="color:red" <%end if%> href="main.asp?id=<%=session("wjjia_id_1")%>&page=<%=pages%>" title="第<%=pages%>页"><%if page=pages then%><%=pages%><%else%>[<u><%=pages%></u>]<%end if%></a><%end if%> 页


<%linenumber=rs.pagesize%>
<%do while (not rs.eof) and (line<linenumber)%>
你需要循环输出的内容

<%rs.movenext%>
<%line=line+1%>
<%loop%>
chenmei 2003-09-25
  • 打赏
  • 举报
回复
page=1
把这句去掉再试试看行不行
xyp730000 2003-09-25
  • 打赏
  • 举报
回复
你的代码太乱了

看不明白哦

^_^^_^
chenmei 2003-09-25
  • 打赏
  • 举报
回复
是不是下一页已是一个链接,但点击出来的却是第一页的东西?
zyy1971 2003-09-25
  • 打赏
  • 举报
回复
不能。
chenmei 2003-09-25
  • 打赏
  • 举报
回复
那直接输入第二页的地址可以显出第二页的记录吗?
gzl 2003-09-25
  • 打赏
  • 举报
回复
楼主发帖得付责任!!这代码没法看,别指望有什么好回答!!














楼主发帖得付责任!!这代码没法看,别指望有什么好回答!!



















楼主发帖得付责任!!这代码没法看,别指望有什么好回答!!
zyy1971 2003-09-25
  • 打赏
  • 举报
回复
我的记录有两页。
zyy1971 2003-09-25
  • 打赏
  • 举报
回复
我的记录有两页。
chenmei 2003-09-25
  • 打赏
  • 举报
回复
是不是你的记录本身只有一页呀?

28,391

社区成员

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

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