| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 869 人关注过本帖
标题:多条件搜索结果页分页问题
只看楼主 加入收藏
gz2008cn
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2009-8-24
结帖率:0
收藏
已结贴  问题点数:20 回复次数:6 
多条件搜索结果页分页问题
我在做一个小程序,有一个多条件搜索功能,但现在搜索出来的结果页却无法成功转到"下一次","最后页".代码如下:
   <%
  action=trim(request.querystring("action"))
  if action="search" then
  selectlb=request("selectlb")
  type1=request("type")
  keyword=request("keyword")
  sql="select * from samplelog where "&selectlb&"='"&keyword&"' and type="&type1&""
   rs.open sql,conn,1,1
if not rs.eof then
const maxperpage=3
dim currentpage
rs.pagesize=maxperpage
currentpage=request("page")
if currentpage="" or not Isnumeric(currentpage) then
currentpage=1
elseif currentpage<1 then
c1urrentpage=1
else
currentpage=clng(currentpage)
    if currentpage > rs.pagecount then
    currentpage=rs.pagecount
    end if
end if
if not isnumeric(currentpage) then
currentpage=1
end if
dim totalput,n
totalput=rs.recordcount
if totalput mod maxperpage=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
if n=0 then
n=1
end if
rs.move(currentpage-1)*maxperpage
i=0
do while i< maxperpage and not rs.eof
i=i+1
    %>
   
<% Set rs1=conn.execute("select * from sample where id="&rs("sampleid")&"") %>
        <tr>
          <td height="33" align="center">&nbsp;
            <label>
            <input name="borrower" type="text" id="borrower" value="<%=rs("id")%>" size="4">
          </label></td>
          <td align="center">&nbsp;
            <label>
            <input name="location" type="text" id="location" value="<%=rs("location")%>" size="10">
          </label></td>
          <td align="center"><%=rs1("itemno")%>
          <td align="center"><%=rs1("PO")%>         
          <td align="center">&nbsp;<%=rs("borrower")%></td>
          <td align="center">&nbsp;
              <%
    if rs("type")=true then
    response.write "N"
    else
    response.Write "Y"
    end if
    %></td>
          <td align="center"><%=rs("borrowedqty")%></td>
          <td align="center"><%=rs("returnedqty")%></td>
          <td align="center">&nbsp;<%=rs("borrow_time")%></td>
          <td align="center">&nbsp;<%=rs("return_time")%></td>
          <td align="center"><label>
            <a href="return1.asp?id='"&borrower&"'>现在归还</a>
          </label></td>
        </tr>
        <%
      rs.movenext
    loop
end if
  rs.close
  set rs=nothing
  %>
        <tr>
    <td colspan="7" align="right">
页数 <font color="red"><%=currentpage%></font>/<% =n%>
    <% k=currentpage                  
       if k<>1 then%>
       [<a class="link" href="borrowlog.asp?<%=keyword%>&type=<%=type1%>&page=1">首页</a>]                  
       [<a class="link" href="borrowlog.asp?<%=selectlb%>=<%=keyword%>&type=<%=type1%>&page=<%=k-1%>">上一页</a>]                  
       <%else%>
       [首页]&nbsp;[上一页]                  
       <%end if%>
       <%if k<>n then%>                  
       [<a class="link" href="borrowlog.asp?<%=selectlb%>=<%=keyword%>&type=<%=type1%>&page=<%=k+1%>">下一页</a>]                  
       [<a class="link" href="borrowlog.asp?<%=selectlb%>=<%=keyword%>&type=<%=type1%>&page=<%=n%>">尾页</a>]                  
       <%else%>
       [下一页]&nbsp;[尾页]                  
       <%end if%>

        共有<font color="red"><%=totalput%></font>条记录 <font color="red"><%=maxperpage%></font>个/页
      共有<font color="red"><%=n%></font>页    </td> <% end if %>
---------------------------------------
结果:


借用号 库位 名称 P/O 借者 是否全部归还 借用数 已归还数 借用时间 最后归还时间  
        1  P   1   N 1 0  2009-8-27 14:58:18   现在归还
        1  P   1   N 1 0  2009-8-27 14:58:39   现在归还
        1  P   1   N 1 0  2009-8-27 15:41:18   现在归还
页数 1/4 [首页] [上一页] [下一页] [尾页] 共有10条记录 3个/页 共有4页

点下页后,无记录出来,但地址栏上是正常的:
https://192.168.1.251/sample/borrowlog.asp?borrower=1&type=true&page=2
搜索更多相关主题的帖子: 结果 条件 搜索 
2009-08-28 10:24
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:10 
参数传递正确 那只能说明搜索语句有问题了 你直接用地址栏的参数构造一个sql查询看看结果对不对
2009-08-28 10:48
gz2008cn
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2009-8-24
收藏
得分:0 
aspic 举例说明一下如何构造?

2009-08-28 10:54
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
直接写sql 然后查询 是access还是mssql的?不过反正都有个类似的查询分析器功能吧 access是视图 输入sql看看结果对不对就知道了
2009-08-28 10:56
gz2008cn
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2009-8-24
收藏
得分:0 
我用的是ACCESS, SQL语句是没有问题的,我都可以搜出结果出来.
2009-08-28 11:03
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:10 
ASP有自己的分页方法已经内置到了ADODB.RecordSet里了,楼主不需要在ASP里自己写算法分页
2009-08-28 13:23
gz2008cn
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2009-8-24
收藏
得分:0 
没用过内置啊!
大家都看不出问题的所在吗?
2009-08-28 14:33
快速回复:多条件搜索结果页分页问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022215 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved