星之卡比梦之泉作弊码:ASP制作网页分页的一个问题,请高手帮忙

来源:百度文库 编辑:高校问答 时间:2024/04/28 16:52:55
我用ASP建立动态网页的时候遇到了一个这样的问题,我建立了一个显示搜索的页面,打开的数据库显示的记录是来自别人的输入,比如别人搜索张学友的歌曲,这时输入的歌手名是张学友,我做的搜索页面打开的数据就是歌手=张学友的数据,显示出来的是张学友的歌曲,但是由于张学友的歌曲太多,就得进行分页显示,问题就出来了,当点"下一页"的时候,网页刷新,这是传过来的歌手变量就不是"张学友"了,因为我前面定义了显示这个页面的数据是来自输入的变量,比如歌手,但是当点"下一页"或者第几页的时候,这时输入的变量就是空的了,张学友第二页上的歌以及其他页面上的歌就显示不出来了,请高手帮忙,怎么解决这个问题?

?geshou=<%=server.URLEncode(Request.Form("geshou"))%>&page=2

将以上参数去掉,添加一个隐藏表单域,<input name='geshou' type='hidden' value='《%=request.form("geshou") %>'>

request.querystring 是用来接收地址里面?后面的xx=xx的内容
而request.form 是用来接收表单递交来的数据

或者你把request.form都改成request()吧。

希望可以帮到你,告诉我你的QQ,我会加你的,我们可以相互学习:)

还是不行啊我的代码是这个,点下一页还是没有数据
<%
geshou=request.form("geshou")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("yinyue.mdb")
%>
<%
exec="select * from yinyue where

geshou='"+geshou+"'"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
if rs.eof and rs.bof then
%>
<p align="center"> </p>
<p align="center">没有相关曲目!</p></td>
</tr><table>
<% else

dim MaxPerPage
dim sql
dim rs
dim gstBookID
dim totalPut
dim CurrentPage
dim TotalPages
filename="geshou.asp"
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
rs.pagesize=10
totalPut=rs.recordcount '记录总数
totalPage=rs.pagecount
MaxPerPage=rs.pagesize
if currentpage<1 then
currentpage=1
end if
if currentpage>totalPage then
currentpage=totalPage
end if
if currentPage=1 then
showContent
showpages1
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark '移动到开始显示的记录

位置
showContent
showpages1
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i,j
%>
<table width="400" align="left" border="0" class="default">
<%
i=1
do while not (rs.eof or err)
%>
<tr>
<td><font color="#990000" face="幼圆"><%=rs("leixing")%></font></td>
<td><font color="#0033CC" face="方正舒体, 方正姚体"><%=rs("geming")%></font></td>
<td><font color="#003333" face="黑体, 华文彩云"><%=rs("geshou")%></font></td>
<td><a href=<%=rs("lianjie")%> target='_blank'>收听</a></td>
<td><a href=<%=rs("xiazai")%> target='_blank'>下载</a></td>
</tr>
<%
if i>=MaxPerPage then exit do
i=i+1
rs.movenext
loop
%>
<tr>
<td height="140" colspan="3" align="center">
<%
end sub
%>
<%
sub showpages1()
dim n
n=totalPage
%>
<form action="<%=filename%>" method="post" align="right">
<table width="81%" height="30" border="0" cellpadding="0" cellspacing="0"

style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td height="30">
<div align="right"> <span style="font-size:9pt"> 共<font

color="#FF0000"><%=totalPage%></font>页/<font color="red"><%=totalPut%></font>条信息

</span>
<% If currentPage <> 1 Then %>
<a href=<%=filename%>><font color="#FF6600"><span style="font-

size:9pt">[首页]</span></font></a> <a href=<%=filename%>?geshou=<%=server.URLEncode

(Request.Form("geshou"))%>&Page=<%=(currentPage-1)%>><font color="#FF6600"><span

style="font-size:9pt">[上一页]</span></font></a>
<% End If %>
<% If currentPage <> rs.PageCount Then %>
<a href=<%=filename%>?geshou=<%=server.URLEncode(Request.Form

("geshou"))%>&Page=<%=(currentPage+1)%>><font color="#FF6600"><span style="font-size:9pt">[

下一页]</span></font></a> <a href=<%=filename%>?Page=<%=totalPage%>><font

color="#FF6600"><span style="font-size:9pt">[尾页]</span></font></a>
<% End If %>
<span style="font-size:9pt"> 第<font color="#FF0000"><%

=currentPage%></font>页/共<font color="#FF0000"><%=totalPage%></font>页
<%
response.write " 转到:<select name='page' size=1 class=smallselsect style='font-family: 宋

体; font-size: 9pt;'>"
for i=1 to n
response.write "<option value="& i
if currentpage=i then
response.write " selected"
end if
response.write ">"& i &"</option>"
next
response.write "</select>"
response.write"<input name='types' type='hidden' value='"&request("types")&"'>"
response.write " <input class=buttonface type='submit' value='go' style='font-

family: 宋体; font-size: 9pt;'>"
%>
</span> </div></td>
</tr>
</table>
</form></td>
</tr>
</table>
<%end sub%>
</div></td>
</tr>
</table>