查询后分页问题,在线等

enthuris 2003-08-20 09:26:08
如果没有查询,分页都是对的,但是查询后,结果也能查到,但只能显示第一页,点击下一页的结果是把一开始显示的记录集显示出来了?代码如下:
<%const MaxPerPage=50
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j

if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
%>
<body bgcolor="#FFFFFF" text="#000000" topmargin="5">

<table width="75%" border="0" bgcolor="eeeeee" align="center">
<form name="form2" method="post" action="">
<tr>
<td colspan="2">搜索</td>
</tr>
<tr>
<td>订单号:
<input type="text" name="Ref_No">
</td>
<td>产品编号:
<input type="text" name="productid">
<input type="submit" name="Submit2" value="搜索">
</td>
</tr></form>
</table>

<p><font size="2">
<%shipid=request.querystring("shipid") '从上一页传递过来的变量
set rs=server.createobject("adodb.recordset")
if request("submit2")<>"" then

Ref_No=request.form("Ref_No")
Productid=request.form("productid")
sql="select * from search where shipid="&shipid&" and Ref_No like '%"&Ref_No&"%' and Productid like '%"&productid&"%' "
rs.open sql,conn,1,1
else
sql="select * from search where shipid="&shipid&" "
rs.open sql,conn,1,1
end if
if rs.eof and rs.bof then
response.write "<p align='center'> 还没有该客户的订单</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if

end if
if currentPage=1 then
showpage totalput,MaxPerPage,"shippingplan2.asp"
showContent
showpage totalput,MaxPerPage,"shippingplan2.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"shippingplan2.asp"
showContent
showpage totalput,MaxPerPage,"shippingplan2.asp"
else
currentPage=1
showpage totalput,MaxPerPage,"shippingplan2.asp"
showContent
showpage totalput,MaxPerPage,"shippingplan2.asp"
end if
end if
rs.close
end if

set rs=nothing
conn.close
set conn=nothing


sub showContent
dim i
i=0
%>
<form name="form1" method="post" action="shippingplan1.asp?shipid=<%=request.querystring("shipid")%>">
<table width="90%" border="0" align="center" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#006699">
<div align="center"><font color="#FFFFFF">订单号</font></div>
</td>
<td bgcolor="#006699">
<div align="center"><font color="#FFFFFF">客户</font></div>
</td>
<td bgcolor="#006699">
<div align="center"><font color="#FFFFFF">客户订单号</font></div>
</td>
<td bgcolor="#006699">
<div align="center"><font color="#FFFFFF">预定交货时间</font></div>
</td>
<td bgcolor="#006699">
<div align="center"><font color="#FFFFFF">产品编号</font></div>
</td>
<td bgcolor="#006699">
<div align="center"><font color="#FFFFFF">数量</font></div>
</td>
<td bgcolor="#006699" width="15%">
<div align="center"><font color="#FFFFFF">单价</font></div>
</td>
<td bgcolor="#006699">
<div align="center"><font color="#FFFFFF">金额</font></div>
</td>
<td bgcolor="006699">  </td>
</tr>
<%do while not rs.eof
set rsc=server.createobject("adodb.recordset")
sql="select * from customer where customerid="&rs("customerid")&""
rsc.open sql,conn,1,1
%>
<tr bgcolor="eeeeee">
<td>
<div align="center"><%=rs("orderid")%> </div>
</td>
<td>
<div align="center"><%=rsc("companyname")%> </div>
</td>
<td>
<div align="center"><%=rs("Ref_No")%> </div>
</td>
<td>
<div align="center"><%=rs("Deliverytime")%></div>
</td>
<td>
<div align="center"><%=rs("productid")%> </div>
</td>
<td>
<div align="center"><%=rs("Quantity")%></div>
</td>
<td width="15%" height="2">
<div align="center"><%=rs("Price")%></div>
</td>
<td>
<div align="center"><%=ccur(rs("Price"))*rs("Quantity")%></div>
</td>
</tr>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
<tr bgcolor="eeeeee">
<td height="10" colspan="9">
<div align="right">
<input type="submit" name="Submit" value="确定">
</div>
</td>
</tr>
</table>
</form>
<div align="center">
<font size="2">
<%
end sub

function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<form method=Post action="&filename&"?customerid="&request("customerid")&"&shipid="&shipid&">"
response.write "<p align='center'><font color='#000080'>>>分页</font> "
if CurrentPage<2 then
response.write "<font color='#000080'>首页 上一页</font> "
else
response.write "<a href="&filename&"?page=1&customerid="&request("customerid")&"&shipid="&shipid&">首页</a> "
response.write "<a href="&filename&"?page="¤tPage-1&"&customerid="&request("customerid")&"&shipid="&shipid&">上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080'>下一页 尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&customerid="&request("customerid")&"&shipid="&shipid
response.write ">下一页</a> <a href="&filename&"?page="&n&"&customerid="&request("customerid")&"&shipid="&shipid&">尾页</a>"
end if
response.write "<font color='#000080'> 页次:</font><strong><font color=red>"¤tPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>个产品 <b>"&maxperpage&"</b>个产品/页</font> "
response.write " <font color='#000080'>转到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput value="¤tpage&">"
response.write "<input class=buttonface type='submit' value=' Goto ' name='cndok'></span></p></form>"

end function
%>
...全文
28 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
enthuris 2003-08-20
  • 打赏
  • 举报
回复
好像还是没改呀,这和我上面的一样啊
甘泉123 2003-08-20
  • 打赏
  • 举报
回复
<%if CurrentPage<2 then%>
<font color="#000080">首页 上一页</font> 
<% else %>
<a href="&filename&"?page=1&customerid="&request("customerid")&"&shipid="&shipid&">首页</a> 
<a href="&filename&"?page="¤tPage-1&"&customerid="&request("customerid")&"&shipid="&shipid&">上一页</a> 
<% end if
if n-currentpage<1 then%>
<font color="#000080">下一页 尾页</font>
<% else %>
<a href="&filename&"?page="&(CurrentPage+1)&"&customerid="&request("customerid")&"&shipid="&shipid&">下一页</a> 
<a href="&filename&"?page="&n&"&customerid="&request("customerid")&"&shipid="&shipid&">尾页</a>
<% end if%>
甘泉123 2003-08-20
  • 打赏
  • 举报
回复
&keyname=<%=keyname%>

28,390

社区成员

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

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