asp搜索分页代码翻页问题
搜索表单代码:<formname="form5"method="post"action="search.asp"><p><inputname="shijianchuxua...
搜索表单代码:
<form name="form5" method="post" action="search.asp">
<p>
<input name="shijianchuxuan" type="text" value="时间初选" size="10" onfocus="this.value=''">
<input name="shijianfuxuan" type="text" value="时间复选" size="10" onfocus="this.value=''">
<input type="submit" name="Submit5" value="开始搜索">
</p>
</form>
上述代码实现时间段查询
见一楼 ,问题就是在翻页查询的时候无法将查询到的参数传递到第二页,第一页查询结果是对的,当我点第下一页时,出现的是空白。代码看了N遍还是找不到原因,所以到这里来请教高手们了。 展开
<form name="form5" method="post" action="search.asp">
<p>
<input name="shijianchuxuan" type="text" value="时间初选" size="10" onfocus="this.value=''">
<input name="shijianfuxuan" type="text" value="时间复选" size="10" onfocus="this.value=''">
<input type="submit" name="Submit5" value="开始搜索">
</p>
</form>
上述代码实现时间段查询
见一楼 ,问题就是在翻页查询的时候无法将查询到的参数传递到第二页,第一页查询结果是对的,当我点第下一页时,出现的是空白。代码看了N遍还是找不到原因,所以到这里来请教高手们了。 展开
3个回答
2010-06-02
展开全部
<!--#include file=conn.asp -->
<%
dim sql
dim ipage
dim filego
dim shijianchuxuan
dim shijianfuxuan
sshijianchuxuan = Request("shijianchuxuan")
sshijianfuxuan = Request("shijianfuxuan")
sql="select * from party where party_date between '"&sshijianchuxuan&"' and '"&sshijianfuxuan&"' order by star_time,repaired desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
rs.PageSize = 10 '每页显示记录数
If Len(Request("page")) = 0 Then
ipage = 1
Else
ipage = Request("page")
End if
rs.AbsolutePage = iPage '显示当前页等于接收的页数
%>
<html>
<title>报修系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css" type="text/css">
<style>
<!--
#fps0 {cursor: hand}
#fps1 {color:#ffffff;}
-->
</style>
<%
Public Function CutStr(Str,LenNum)
Dim P_num
Dim I,X
If Len(Str)<=LenNum Then
Cutstr=Str
Else
P_num=0
X=0
Do While Not P_num > LenNum-2
X=X+1
If Asc(Mid(Str,X,1))<0 Then
P_num=Int(P_num) + 2
Else
P_num=Int(P_num) + 1
End If
Cutstr=Left(Trim(Str),X)&"…"
Loop
End If
End Function
%>
<BODY LEFTMARGIN="0" MARGINWIDTH="0" TOPMARGIN="2" MARGINHEIGHT="2" style="text-align:center" background="images/bg.gif">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#CCCCCC" align="center">
<tr align="center" bgcolor="#C4E8FF">
<td width="5%" height="25"><div align="center"><strong>编号</strong></div></td>
<td width="16%" height="25"><div align="left"><strong>部门</strong></div></td>
<td width="34%"><div align="left"><strong>报修原因</strong></div></td>
<td width="10%" height="25"><div align="left"><strong>报修类别</strong></div></td>
<td width="7%"><div align="left"><strong>报修人</strong></div></td>
<td width="11%" height="25"><div align="left"><strong>报修时间</strong></div></td>
<td width="7%" height="25"><div align="left"><strong>是否修复</strong></div></td>
<td width="10%" height="25"><div align="left"><strong> 修复时间</strong></div></td>
</tr>
<%
For i =1 To rs.PageSize
If Not rs.Eof Then
%>
<%party_id=rs("party_id")%>
<tr align="center" bgcolor="#FFFFFF">
<td height="21" width="5%" bgcolor="#FFFFFF"><div align="center"><%=rs("party_id")%></div></td>
<td height="21" width="16%" bgcolor="#FFFFFF"><div align="left"><%=rs("party_add")%>-<%=rs("party_Sign")%></div></td>
<td width="34%"><div align="left"><a href=partyxs2.asp?party_id=<%=party_id%> ><%=CutStr(rs("yuanyin"),60)%></a></div></td>
<td width="10%" height="21"><div align="left"><a><%=rs("party_link")%><font color="#0066FF"></font></a></div></td>
<td width="7%"><div align="left"><%=rs("party_user")%></div></td>
<td width="11%" height="21"><div align="left"><font color="#0000FF"><%=rs("star_time")%></font></div></td>
<td width="7%" height="21"><div align="left"><font color="#0000FF">
<% set rsb=server.createobject("adodb.recordset")
sql="select * from guestbook where party_id=" & party_id
rsb.open sql,conn,1,1
%>
<%=rs("repaired")%></font></div></td>
<td width="10%" height="21"><div align="left"><font color="#0000FF"><%=rs("smtime")%> <%=rs("finishtime")%></font>
<% rsb.Close
Set rsb = Noting
%>
</div></td>
</tr>
<%
End if
If Not rs.Eof Then rs.movenext
Next
%>
</table></td>
</tr>
</table>
<%
sql="select * from party order by star_time desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<p align='center'>暂时没有信息!</p>"
end if
%>
<%
If CInt(ipage) = 1 Then
%>
第一页|上一页|
<%
Else
%>
<a href="chasearch5.asp?page=1">第一页</a>|
<a href="chasearch5.asp?page=<%=ipage-1%>">上一页</a>|
<%
End If
%>
<%
If CInt(ipage) = CInt(rs.PageCount) Then
%>
下一页|最后一页
<%
Else
%>
<a href="chasearch5.asp?page=<% = ipage + 1 %>">下一页</a>|
<a href="chasearch5.asp?page=<% = rs.PageCount %>">最后一页</a>
<%
End If
%>
<%
rs.close
Set rs = Nothing
%>
</p>
</BODY>
</HTML>
<%
dim sql
dim ipage
dim filego
dim shijianchuxuan
dim shijianfuxuan
sshijianchuxuan = Request("shijianchuxuan")
sshijianfuxuan = Request("shijianfuxuan")
sql="select * from party where party_date between '"&sshijianchuxuan&"' and '"&sshijianfuxuan&"' order by star_time,repaired desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
rs.PageSize = 10 '每页显示记录数
If Len(Request("page")) = 0 Then
ipage = 1
Else
ipage = Request("page")
End if
rs.AbsolutePage = iPage '显示当前页等于接收的页数
%>
<html>
<title>报修系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css" type="text/css">
<style>
<!--
#fps0 {cursor: hand}
#fps1 {color:#ffffff;}
-->
</style>
<%
Public Function CutStr(Str,LenNum)
Dim P_num
Dim I,X
If Len(Str)<=LenNum Then
Cutstr=Str
Else
P_num=0
X=0
Do While Not P_num > LenNum-2
X=X+1
If Asc(Mid(Str,X,1))<0 Then
P_num=Int(P_num) + 2
Else
P_num=Int(P_num) + 1
End If
Cutstr=Left(Trim(Str),X)&"…"
Loop
End If
End Function
%>
<BODY LEFTMARGIN="0" MARGINWIDTH="0" TOPMARGIN="2" MARGINHEIGHT="2" style="text-align:center" background="images/bg.gif">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#CCCCCC" align="center">
<tr align="center" bgcolor="#C4E8FF">
<td width="5%" height="25"><div align="center"><strong>编号</strong></div></td>
<td width="16%" height="25"><div align="left"><strong>部门</strong></div></td>
<td width="34%"><div align="left"><strong>报修原因</strong></div></td>
<td width="10%" height="25"><div align="left"><strong>报修类别</strong></div></td>
<td width="7%"><div align="left"><strong>报修人</strong></div></td>
<td width="11%" height="25"><div align="left"><strong>报修时间</strong></div></td>
<td width="7%" height="25"><div align="left"><strong>是否修复</strong></div></td>
<td width="10%" height="25"><div align="left"><strong> 修复时间</strong></div></td>
</tr>
<%
For i =1 To rs.PageSize
If Not rs.Eof Then
%>
<%party_id=rs("party_id")%>
<tr align="center" bgcolor="#FFFFFF">
<td height="21" width="5%" bgcolor="#FFFFFF"><div align="center"><%=rs("party_id")%></div></td>
<td height="21" width="16%" bgcolor="#FFFFFF"><div align="left"><%=rs("party_add")%>-<%=rs("party_Sign")%></div></td>
<td width="34%"><div align="left"><a href=partyxs2.asp?party_id=<%=party_id%> ><%=CutStr(rs("yuanyin"),60)%></a></div></td>
<td width="10%" height="21"><div align="left"><a><%=rs("party_link")%><font color="#0066FF"></font></a></div></td>
<td width="7%"><div align="left"><%=rs("party_user")%></div></td>
<td width="11%" height="21"><div align="left"><font color="#0000FF"><%=rs("star_time")%></font></div></td>
<td width="7%" height="21"><div align="left"><font color="#0000FF">
<% set rsb=server.createobject("adodb.recordset")
sql="select * from guestbook where party_id=" & party_id
rsb.open sql,conn,1,1
%>
<%=rs("repaired")%></font></div></td>
<td width="10%" height="21"><div align="left"><font color="#0000FF"><%=rs("smtime")%> <%=rs("finishtime")%></font>
<% rsb.Close
Set rsb = Noting
%>
</div></td>
</tr>
<%
End if
If Not rs.Eof Then rs.movenext
Next
%>
</table></td>
</tr>
</table>
<%
sql="select * from party order by star_time desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<p align='center'>暂时没有信息!</p>"
end if
%>
<%
If CInt(ipage) = 1 Then
%>
第一页|上一页|
<%
Else
%>
<a href="chasearch5.asp?page=1">第一页</a>|
<a href="chasearch5.asp?page=<%=ipage-1%>">上一页</a>|
<%
End If
%>
<%
If CInt(ipage) = CInt(rs.PageCount) Then
%>
下一页|最后一页
<%
Else
%>
<a href="chasearch5.asp?page=<% = ipage + 1 %>">下一页</a>|
<a href="chasearch5.asp?page=<% = rs.PageCount %>">最后一页</a>
<%
End If
%>
<%
rs.close
Set rs = Nothing
%>
</p>
</BODY>
</HTML>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在翻页的时候必须要把本页的参数传递过去,给你简单举个例子
你的搜索代码
获取你输入的值,假设是开始时间和技术时间
sdate=request("shijianchuxuan")
edate=request("shijianfuxuan")
sql="select * from 表名 where 条件"
显示数据
--下面是分页
<a href="?pagenum=<%=当前页-1%>&sdate=<%=sdate%>&edate=<%=edate%>">上一页</a>
注意页码后面的参数,是把你搜索的条件也带上去了。
你的搜索代码
获取你输入的值,假设是开始时间和技术时间
sdate=request("shijianchuxuan")
edate=request("shijianfuxuan")
sql="select * from 表名 where 条件"
显示数据
--下面是分页
<a href="?pagenum=<%=当前页-1%>&sdate=<%=sdate%>&edate=<%=edate%>">上一页</a>
注意页码后面的参数,是把你搜索的条件也带上去了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2010-06-02
展开全部
没有传参数,应该这样写:
<form name="form5" method="post" action="search.asp?page_no=1&keyword="&request("keyword")&"&class="&request("class")&" ">
<p>
<input name="shijianchuxuan" type="text" value="时间初选" size="10" onfocus="this.value=''">
<input name="shijianfuxuan" type="text" value="时间复选" size="10" onfocus="this.value=''">
<input type="submit" name="Submit5" value="开始搜索">
</p>
</form>
<form name="form5" method="post" action="search.asp?page_no=1&keyword="&request("keyword")&"&class="&request("class")&" ">
<p>
<input name="shijianchuxuan" type="text" value="时间初选" size="10" onfocus="this.value=''">
<input name="shijianfuxuan" type="text" value="时间复选" size="10" onfocus="this.value=''">
<input type="submit" name="Submit5" value="开始搜索">
</p>
</form>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询