急...这该死的分页...折腾死人了.

jxyy601 2008-04-28 10:30:25

<%
dim kind,tree_name,Page,thePageSize,ttlPage,i,ttlRDCnt

kind=Request("kind")
tree_name=Request("tree_name")

tree_name=replace(tree_name,"!","")
tree_name=replace(tree_name,"~","")
tree_name=replace(tree_name,"`","")

if kind="不要求" and tree_name="" then Response.Redirect("../supply_list.asp") end if

dim objRs,sqlStr
set objRs=Server.CreateObject("ADODB.Recordset")
sqlStr="select * from purvey "

if kind<>"不要求" or tree_name<>"" then
sqlStr=sqlStr & " where"
end if
if kind<>"不要求" then
sqlStr=sqlStr & " kind='"&kind&"'"
end if
if kind<>"不要求" and tree_name<>"" then
sqlStr=sqlStr & " and "
end if
if tree_name<>"" then
sqlStr=sqlStr & " tree_name='"&tree_name&"'"
end if
Response.Write(sqlStr)
objRs.open sqlStr,objConn,3,2
%>

<%
thePageSize=2 '定义每页最多显示文章数
page=Request("Page")

if not IsNumeric(Page) then
Page=1
else
Page=Clng(Page)
end if

if Page<=1 then
Page=1
end if

if not objRs.eof then
objRs.PageSize=thePageSize
ttlPage=objRs.PageCount
ttlRDCnt=objRs.Recordcount
end if

if Page>ttlPage then
Page=ttlPage
objRs.AbsolutePage=Page
end if
%>

.....

<%
for i=1 to thePageSize
if objRs.eof then exit for
%>
<tr>
<td height="25" align="center" valign="bottom" class="under_line_ccc"><%= objRs("tree_name") %></td>
<td align="center" valign="bottom" bgcolor="#f2f5fe" class="under_line_ccc">W:<%= objRs("coronal") %>,
H:<%= objRs("hight")% >,Φ:<%= objRs("chest") %></td>
<td align="center" valign="bottom" class="under_line_ccc"><%= objRs("unit") %></td>
<td align="center" valign="bottom" bgcolor="#f2f5fe" class="under_line_ccc"><%= objRs("kind") %>类</td>
<td align="center" valign="bottom" class="under_line_ccc"><a href="supply_seach_view.asp#?trees_id=<%= objRs("id") %>" title="点击查看更详细信息" target="ads_pop"><font color="#666666">查看详细</font></a></td>
</tr>
<% objRs.movenext
next
end if
%>

....
<td height="23" colspan="5" valign="top">
<% if ttlRDCnt>2 then %>
<font color="#000000">共</font><font color="#666666"><%= ttlRDCnt%></font><font color="#000000">条信</font><font color="#000000">息 每页</font><font color="#666666"><%= thePageSize %></font><font color="#000000">条 当前第</font><font color="#666666"><%= Page %></font><font color="#000000">页</font> <font color="#666666">|</font> <font color="#000000">选择</font>
<% for i=1 to ttlPage %>
<a href="supply_list.asp?Page=<%= i %>"><font color="#666666"><%= i %></font></a>
<% next %>
<font color="#000000"> ... </font> <a href="supply_list.asp?Page=<%= Page-1 %>&kind=<%= kind %>&tree_name=<%=tree_name %>" target="ads_pop"><font color="#000000">上一页</font></a>
  <a href="supply_list.asp?Page=<%=Page+1 %>&kind=<%=kind %>&tree_name=<%=tree_name %>" target="ads_pop"><font color="#000000"> 下一页</font></a>
<% end if %>
</td>
这个对查询结果的分页.不知错在那儿了,折腾好久了都没搞定,一点击"上一页或下一页"就出现"找不到该网页错误"
唉,人太笨了,没法.寻求好心人解答万分感谢!
...全文
120 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
mysite365 2008-04-29
  • 打赏
  • 举报
回复

dim objRs,sqlStr
set objRs=Server.CreateObject("ADODB.Recordset")
sqlStr="select * from purvey "

if kind<>"不要求" or tree_name<>"" then
sqlStr=sqlStr & " where"
end if
if kind<>"不要求" then
sqlStr=sqlStr & " kind='"&kind&"'"
end if
if kind<>"不要求" and tree_name<>"" then
sqlStr=sqlStr & " and "
end if
if tree_name<>"" then
sqlStr=sqlStr & " tree_name='"&tree_name&"'"
end if

你的这里逻辑有问题,看看我的把:
<% dim nameky,checkbox
namekey=str_filter(request.Form("namekey"))
checkbox=request.Form("checkbox")
set rs=server.createobject("adodb.recordset")
if namekey="" then
rs.open "select * from [bout_user] where flag=0 order by userid desc",conn,1,3
else
if checkbox="1" then
rs.open "select * from [bout_user] where flag=0 and turename like '%"&namekey&"%' order by userid desc",conn,1,3
else
rs.open "select * from [bout_user] where flag=0 and turename like '"&namekey&"' order by userid desc",conn,1,3
end if
end if



分页时候用 rs.open sql,conn,1,1 你的这就话也不对
rs.open sql,conn,1,3 同样可以,实践证明。
lcw321321 2008-04-29
  • 打赏
  • 举报
回复

if kind<>"不要求" or tree_name<>"" then
sqlStr=sqlStr & " where"
end if
if kind<>"不要求" then
sqlStr=sqlStr & " kind='"&kind&"'"
end if
if kind<>"不要求" and tree_name<>"" then
sqlStr=sqlStr & " and "
end if
if tree_name<>"" then
sqlStr=sqlStr & " tree_name='"&tree_name&"'"
end if


感觉逻辑有点乱乱的
jhwcd 2008-04-29
  • 打赏
  • 举报
回复
你用存贮过程分页比较好一点,执行也比较快.
yyusnO 2008-04-29
  • 打赏
  • 举报
回复
把你的提交页发上来
bhtfg538 2008-04-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 suiye 的回复:]
if objRs.eof then exit for 这句错了 if objRs.eof then exit for end if
应该是的
[/Quote]
对了 怎么不对啊 写在一行不用 end if
分页时候用 rs.open sql,conn,1,1

if Page>ttlPage then
Page=ttlPage
objRs.AbsolutePage=Page
这句话 objRs.AbsolutePage=Page
位置错误了
objRs.AbsolutePage=Page
你都没有获得当前页怎么分
snlixing 2008-04-29
  • 打赏
  • 举报
回复
有“supply_list.asp”这一页吗
tantaiyizu 2008-04-29
  • 打赏
  • 举报
回复
sdfsdf
jxyy601 2008-04-29
  • 打赏
  • 举报
回复
已解决,感谢各位提供帮忙....
街头小贩 2008-04-29
  • 打赏
  • 举报
回复
在这也能搜到不少封装好的分页函数!
ymle1228 2008-04-29
  • 打赏
  • 举报
回复
sub showpages()
dim n
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
if n=1 then
exit sub
end if
dim k
response.write " <align='left'>>> 分页 "
for k=1 to n
if k=currentPage then
response.write " <font color='#FF0000'>[ <b>"+Cstr(k)+" </b>] </font> "
else
response.write "[ <b>"+" <a href='dslamlist.asp?page="+cstr(k)+"&lookword="+lookword+"'>"+Cstr(k)+" </a> </b>] "
end if
next
end sub


这是我的分页函数,移放到不同的页面稍稍改一下下就可以了!
fishidea 2008-04-29
  • 打赏
  • 举报
回复
够乱的,给你段代码吧^_^

<%
sql = ""
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3

if not(rs.eof and rs.bof) then
totalRec=rs.recordcount
if rs.recordcount mod MSG_PER_NL =0 then
n=rs.recordcount \ MSG_PER_NL
else
n=rs.recordcount \ MSG_PER_NL + 1
end if
S.PageSize=MSG_PER_NL
currentpage = Request("page")
If currentpage <> "" then
currentpage = cint(currentpage)
if currentpage<1 then
currentpage = 1
end if
if err.number<>0 then
err.clear
currentpage=1
end if
else
currentpage = 1
End if
if currentpage*MSG_PER_NL>totalrec and not((currentpage-1)*MSG_PER_NL<totalrec) then
currentPage=1
end if
Rs.AbsolutePage = currentpage
RowCount = rs.PageSize
do while not rs.eof and rowcount > 0
%>
//列表<table>
<%
rowcount=rowcount-1
rs.movenext
loop
end if
%>
allen0228 2008-04-28
  • 打赏
  • 举报
回复
if objRs.eof then exit for 这句错了 if objRs.eof then exit for end if
应该是的
jxyy601 2008-04-28
  • 打赏
  • 举报
回复
很抱谦,发完贴发现上一页及选择页数作没有修改,就仅对"下一页"作测试吧.各位大侠帮帮忙啊.

28,391

社区成员

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

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