分页问题

sumjor 2009-08-01 02:18:56
<%
m1=request.Form("acreage1")
m2=request.Form("acreage2")
bianhao=request.Form("bianhao")
jy_id=request.Form("jy_id")
qu_id=request.Form("qu_id")
hu_id=request.Form("hu_id")
updatetime=request.Form("updatetime")
luduan="%"&trim(request.Form("key"))&"%"
sheshi="%"&trim(request.Form("key1"))&"%"
%>
。。
<%
set Rs=Server.CreateObject("Adodb.Recordset")
sql="select id,m,num,qu_id,jy_id,hu_id,date,luduan,estab,floor,money from info where 1=1"
if m1<>""then
sql=sql&" and clng(m)>"&clng(m1)
end if
if m2<>"" then
sql=sql&" and clng(m)<"&clng(m2)
end if
if bianma<>"" then
sql=sql &"and num='"&bianma&"'"
end if
if qu_id<>"" then
sql=sql & "and qu_id='"&qu_id&"'"
end if
if jy_id<>"不限" then
sql = sql & "and jy_id='"&jy_id&"'"
end if
if hu_id<>"不限" then
sql = sql & "and hu_id='"&hu_id&"'"
end if
if clng(updatetime)<>0 then
sql=sql & "and date>date-"&clng(updatetime)
end if
if luduan<>"" then
sql=sql&"and luduan like '"&luduan&"'"
end if
if sheshi<>"" then
sql=sql & "and estab like '"&sheshi&"'"
end if
Rs.open sql,conn,1,1
If Not (rs.eof and rs.bof) Then
rs.pagesize=20 '定义每页显示的记录数
pages=clng(Request("pages")) '获得当前页数
If pages<1 Then pages=1
If pages>rs.recordcount Then pages=rs.recordcount
showpage rs,pages '执行分页子程序showpage
Sub showpage(rs,pages) '分页子程序showpage(rs,pages)
rs.absolutepage=pages '指定指针所在的当前位置
For i=1 to rs.pagesize '循环显示记录%>
<tr bgcolor="#F7F7F7" class="tab11">
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("num")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("qu_id")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("luduan")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("hu_id")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("floor")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("m")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("money")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><font color="#000000"><%=rs("jy_id")%></font></span></td>
<td height="22" align="center"><span style="font-size: 9pt"><a style="cursor:hand;" onclick='window.open("show_source.asp?id=<%=rs("id")%>&type=2","","alwaysRaised=yes,resizable=no,minimizebutton=no,scrollbars=yes,width=580,height=500")'>
<font color="#000000">详细信息</font></a></span></td>
</tr>
<%
n=n+1
rs.movenext '指针向下移动
If rs.eof Then exit for
Next
End Sub
%>
</table>
<form name="form" action="?" method="get">

<%
If rs.recordcount > rs.pagesize Then
if pages<>1 then
response.Write("  <a href="&path&"?pages=1&action="&action&">首页</a>")
response.Write("  <a href="&path&"?pages="&(pages-1)&">上一页</a>")
end if
response.Write("  当前 <font color='#FF0000'>"&pages&"/"&rs.pagecount&"</font> 页")
if pages<>rs.pagecount then
response.Write("  <a href="&path&"?pages="&(pages+1)&">下一页</a>")
response.Write("  <a href="&path&"?pages="&rs.pagecount&">末页</a>")
end if
rs.close
Set rs=Nothing
End If
%>
</form>
</tr>
<%Else%>
<tr>
<td align="center"><span class="STYLE2">此栏目暂无商品信息,请稍后查看!</span></td>
</tr>
<%End If%>
分页后第一页可以显示数据,但是第二页以后什么都没有,大家看看哪里出错了
...全文
76 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
凡夫与俗子 2009-08-01
  • 打赏
  • 举报
回复
好多码~!
sumjor 2009-08-01
  • 打赏
  • 举报
回复
嗯 应该是数据问题 我正在改
jiyi30215 2009-08-01
  • 打赏
  • 举报
回复
你这分页。没问题吧。要不就是你数据问题。
我用我这边的数据测试分页没出错阿。




<!--#include file="accond/conn.asp"-->
。。<table>
<%
set Rs=Server.CreateObject("Adodb.Recordset")
sql="select * from userr "
Rs.open sql,conn,1,1
If Not (rs.eof and rs.bof) Then
rs.pagesize=20 '定义每页显示的记录数
pages=clng(Request("pages")) '获得当前页数
If pages <1 Then pages=1
If pages>rs.recordcount Then pages=rs.recordcount
showpage rs,pages '执行分页子程序showpage
Sub showpage(rs,pages) '分页子程序showpage(rs,pages)
rs.absolutepage=pages '指定指针所在的当前位置
For i=1 to rs.pagesize '循环显示记录%>
<tr bgcolor="#F7F7F7" class="tab11">
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"> <%=rs("id")%> </font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"> <%=rs("id")%></font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"> <%=rs("id")%> </font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"> <%=rs("id")%></font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"> <%=rs("id")%> </font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"><%=rs("id")%> </font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"> <%=rs("id")%> </font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <font color="#000000"> <%=rs("id")%></font> </span> </td>
<td height="22" align="center"> <span style="font-size: 9pt"> <a style="cursor:hand;" onclick='window.open("show_source.asp?id= <%=rs("id")%>&type=2","","alwaysRaised=yes,resizable=no,minimizebutton=no,scrollbars=yes,width=580,height=500")'>
<font color="#000000">详细信息 </font> </a> </span> </td>
</tr>
<%
n=n+1
rs.movenext '指针向下移动
If rs.eof Then exit for
Next
End Sub
%>
</table>

<form name="form" action="" method="get">
<% If rs.recordcount > rs.pagesize Then
if pages <>1 then
response.Write("   <a href="&path&"?pages=1&action="&action&">首页 </a>")
response.Write("   <a href="&path&"?pages="&(pages-1)&">上一页 </a>")
end if
response.Write("  当前 <font color='#FF0000'>"&pages&"/"&rs.pagecount&" </font> 页")
if pages <>rs.pagecount then
response.Write("   <a href="&path&"?pages="&(pages+1)&">下一页 </a>")
response.Write("   <a href="&path&"?pages="&rs.pagecount&">末页 </a>")
end if
rs.close
Set rs=Nothing
End If
%>
</form>

<%End If%>
roger_lmj 2009-08-01
  • 打赏
  • 举报
回复
如果你是MyEclipse得话试试debug,这样好弄些,看是那步的问题这样就Ok了
代码太密了

28,409

社区成员

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

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