标题:多条件搜索后第一页显示正常,点下一页就变成全部记录了,请大侠出手!
只看楼主
xzliqinghua
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-9-22
结帖率:0
已结贴  问题点数:20 回复次数:9 
多条件搜索后第一页显示正常,点下一页就变成全部记录了,请大侠出手!
源代码如下:
<table id="__01"  border="0" cellpadding="0" cellspacing="0" align=center>

<tr>
        <td width="44" height="112">
            <img src="stimg/main1_01.gif"></td>
        <td width="202" height="112">
            <img src="stimg/main1_02.gif"></td>
        <td width="24" height="112">
            <img src="stimg/main1_03.gif"></td>
        <td width="632" height="112" >
            <img src="stimg/main1_04.gif" ></td>
        <td width="48" height="112" >
            <img src="stimg/main1_05.gif" ></td>
    </tr>
    <tr>
        <td  width="44" height="40" valign="top">
            <img src="stimg/main1_06.gif"></td>
        <td width="202" height="40"  valign="top">
            <img src="stimg/main1_07.gif" ></td>
        <td  width="24" height="40" valign="top">
            <img src="stimg/main1_08.gif" ></td>
        <td width="632" height="40" valign="top">
            <img src="stimg/main1_09.gif" ></td>
        <td width="48" height="40"  valign="top">
            <img src="stimg/main1_10.gif"  ></td>
    </tr>
    <tr>
        <td width="44" height="608"  valign="top">
            <img src="stimg/main1_11.gif" ></td>
        <td width="202" height="608" valign="top"><table width="202" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="202" height="461">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.,0,19,0" width="202" height="458">
  <param name="movie" value="main.swf">
  <param name="quality" value="high">
  <embed src="main.swf" quality="high" pluginspage="http://www. type="application/x-shockwave-flash" width="202" height="458"></embed>
</object>


 </td>
          </tr>
          <tr>
            <td width="202" height="147"><img src="stimg/13.gif"></td>
          </tr>
        </table></td>
        <td width="24" height="608" valign="top">
            <img src="stimg/main1_13.gif"></td>
<%
dim name,sex,xk,lwname,lwjb,lwtime,lwzz,lwbz,updatetime,ip,rs,db

name=trim(request.form("name"))
sex=trim(request.form("sex"))
xk=trim(request.form("xk"))
lwname=trim(request.form("lwname"))
lwjb=trim(request.form("lwjb"))
lwtime=trim(request.form("lwtime"))

lwzz=trim(request.form("lwzz"))

lwbz=trim(request.form("lwbz"))
%>
        <td  width="632" height="600" valign="top">
<%
MyPageSize   = 4          '每页显示多少文章
If Not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Or Request("page") <=0 Then
MyPage=1
Else
MyPage=Int(Abs(Request("page")))
End if
%>
<%
db="2010xzxxhjdj.asp"      '数据库文件的位置
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open connstr

set rs=server.createobject("adodb.recordset")

 strSql = "select * from tlw where 1=1 "
    If name  <> "" then
    strSql = strSql & " and name like '%" & name & "%'"
    end if
        if sex <> "" then
      strsql = strsql & " and sex like '%" & sex & "%'"
    end if
    if xk<> "" then
          strSql = strSql & " and xk like '%" & xk & "%'"
    end if
        
    if lwjb<> "" then
         strSql = strSql & " and lwjb like '%" & lwjb & "%'"
    end if
        
    if lwbz<> "" then
          strSql = strSql & " and lwbz like '%" & lwbz & "%'"
    end if   

    if lwtime<> "" then
          strSql = strSql & " and lwtime like '%" & lwtime & "%'"
    end if   
   
rs.open strsql,conn,1,1
if not rs.eof then

rs.PageSize      = MyPageSize
MaxPages         = rs.PageCount
rs.absolutepage  = MyPage

total            = rs.RecordCount

for i=1 to rs.PageSize
       if not rs.eof then

%>
<table align=center  border=1 width=622 id="listView">
<tr><th colspan="6">成果信息</th></tr>   
<tr>
  <td width="102" >姓&nbsp;&nbsp; 名</td>
    <td width="101" ><%=rs("name")%></td>
    <td width="90" >性&nbsp;&nbsp; 别</td>
    <td width="80" ><%=rs("sex")%></td>
    <td width="90" >获奖分类</td>
    <td width="109" ><%=rs("xk")%></td>
</tr>
<tr>
  <td width="102" >获奖名称</td>
    <td colspan=3 width="220" ><%=rs("lwname")%></td>
   
    <td width="90" >获奖级别</td>
    <td width="109" ><%=rs("lwjb")%></td>
</tr>
<tr>
 
    <td width="90" >组织单位</td>
    <td colspan=3 width="220" ><%=rs("lwzz")%></td>
 <td width="108" >获得成果时间</td>
    <td width="101" ><%=rs("lwtime")%></td>
   
</tr>


<tr>
  <td width="102" >成果备注</td>
    <td colspan=5 width="250" ><%=rs("lwbz")%></td>
   
</tr>
</table>
<%
    rs.movenext
    end if
    next
else
response.write "对不起,没有符合要求的成果信息记录"
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<table align=center  border=1 bordercolor="#67C1E4" width=622>
<%
url="?"
                           
    dim n, i,strTemp
    if total mod MyPageSize=0 then
        n= total \ MyPageSize
      else
        n= total \ MyPageSize+1
      end if
      strTemp= "<tr><td align='center' class=black colspan=5>"
        strTemp=strTemp & "共<b>"&total&"</b>名&nbsp;"
      if MyPage<2 then
            strTemp=strTemp & "首页 上页&nbsp;"
      else
            strTemp=strTemp & "<a href='"&Url& "page=1'>首页</a>&nbsp;"
            strTemp=strTemp & "<a href='"&Url& "page="&(MyPage-1)&"'>上页</a>&nbsp;"
      end if

      if n-MyPage<1 then
            strTemp=strTemp & "下页 尾页"
      else
            strTemp=strTemp & "<a href='"&Url& "page="&(MyPage+1)&"'>下页</a>&nbsp;"
            strTemp=strTemp & "<a href='"&Url& "page="&n& "'>尾页</a>"
      end if
       strTemp=strTemp & "&nbsp;页次:<strong><font color=red>"&MyPage&"</font>/"&n&"</strong>页"
    strTemp=strTemp & "<b>"&MyPageSize&"</b>  名/页"
        strTemp=strTemp & "转到:<select name='page' size='1' onChange=""javascript:window.location='"&Url& "page=" & "'+this.options[this.selectedIndex].value;"" class='input'>"   
        for i = 1 to n   
            strTemp=strTemp & "<option value='"&i&"'"
            if cint(MyPage)=cint(i) then strTemp=strTemp & " selected "
            strTemp=strTemp & ">第" & i & "页</option>"   
        next
        strTemp=strTemp & "</select>"
    strTemp=strTemp & "</td></tr>"
    response.write strTemp
%>
</table>      </td>
        <td  width="48" height="608" valign="top"><img src="stimg/main1_15.gif"></td>
    </tr>
</table>
<table   border="0" cellpadding="0" cellspacing="0" align=center valign=top>
    <tr>
        <td width="44" height="110" >
            <img src="stimg/main1_16.gif"></td>
        <td width="202" height="110" >
            <img src="stimg/main1_17.gif"></td>
        <td width="24" height="110">
            <img src="stimg/main1_18.gif"></td>
        <td width="632" height="110">
            <img src="stimg/main1_19.gif"></td>
        <td width="48" height="110" >
            <img src="stimg/main1_20.gif" ></td>
    </tr>
</table>


</body>
</html>
搜索更多相关主题的帖子: 记录 条件 搜索 
2010-09-22 23:08
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
得分:10 
你传值方式问题。
将表里的传送方式改为 get

接受里用 request("name").....

QQ:63572063
2010-09-22 23:41
xzliqinghua
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-9-22
得分:0 
改了还是一样,关键是搜索关键字没有传递呀,不知道asp搜索后分页如何传递sql,点下一页后,变成全部记录了。还是要请大侠出手相助!
2010-09-24 00:29
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
得分:0 
url="?"
再改成:
url="?" & Request.QueryString &"&"

QQ:63572063
2010-09-24 12:43
xzliqinghua
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-9-22
得分:0 
谢谢你啊,我再试试看。
2010-09-24 19:14
xzliqinghua
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-9-22
得分:0 
还是没有用啊。
2010-09-24 19:31
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
得分:0 
你表单页的表单提交方式改成"Get"了没有啊?应该可以的呀。
把你改好的发上来我看看。

QQ:63572063
2010-09-25 17:14
xzliqinghua
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-9-22
得分:0 
已经按要求改了,源码如下,还是不行,不知哪里有错误。
<%
url="?"
                           
    dim n, i,strTemp
    if total mod MyPageSize=0 then
        n= total \ MyPageSize
      else
        n= total \ MyPageSize+1
      end if
      strTemp= "<tr><td align='center' class=black colspan=5>"
        strTemp=strTemp & "共<b>"&total&"</b>名&nbsp;"
      if MyPage<2 then
            strTemp=strTemp & "首页 上页&nbsp;"
      else
            strTemp=strTemp & "<a href='"&Url& "page=1'>首页</a>&nbsp;"
            strTemp=strTemp & "<a href='"&Url&Request.QueryString("name")&Request.QueryString("sex")&Request.QueryString("xk")&Request.QueryString("name")&Request.QueryString("lwname")&Request("lwjb").QueryString&Request.QueryString("lwtime")&Request.QueryString("lwbz")&Request.QueryString("lwzz")& "page="&(MyPage-1)&"'>上页</a>&nbsp;"
      end if

      if n-MyPage<1 then
            strTemp=strTemp & "下页 尾页"
      else
            strTemp=strTemp & "<a href='"&Url&Request.QueryString("name")&Request.QueryString("sex")&Request.QueryString("xk")&Request.QueryString("name")&Request.QueryString("lwname")&Request.QueryString("lwjb")&Request.QueryString("lwtime")&Request.QueryString("lwbz")&Request.QueryString("lwzz")& "page="&(MyPage+1)&"'>下页</a>&nbsp;"
            strTemp=strTemp & "<a href='"&Url& "page="&n& "'>尾页</a>"
      end if
       strTemp=strTemp & "&nbsp;页次:<strong><font color=red>"&MyPage&"</font>/"&n&"</strong>页"
    strTemp=strTemp & "<b>"&MyPageSize&"</b>  名/页"
        strTemp=strTemp & "转到:<select name='page' size='1' onChange=""javascript:window.location='"&Url& "page=" & "'+this.options[this.selectedIndex].value;"" class='input'>"   
        for i = 1 to n   
            strTemp=strTemp & "<option value='"&i&"'"
            if cint(MyPage)=cint(i) then strTemp=strTemp & " selected "
            strTemp=strTemp & ">第" & i & "页</option>"   
        next
        strTemp=strTemp & "</select>"
    strTemp=strTemp & "</td></tr>"
    response.write strTemp
%>
2010-09-26 07:18
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
得分:0 
<%
url="?"&Request.QueryString("name")&Request.QueryString("sex")&Request.QueryString("xk")&Request.QueryString("lwname")&Request.QueryString("lwjb")&Request.QueryString("lwtime")&Request.QueryString("lwbz")&Request.QueryString("lwzz")&"&"
                           
    dim n, i,strTemp
    if total mod MyPageSize=0 then
        n= total \ MyPageSize
      else
        n= total \ MyPageSize+1
      end if
      strTemp= "<tr><td align='center' class=black colspan=5>"
        strTemp=strTemp & "共<b>"&total&"</b>名&nbsp;"
      if MyPage<2 then
            strTemp=strTemp & "首页 上页&nbsp;"
      else
            strTemp=strTemp & "<a href='"&Url& "page=1'>首页</a>&nbsp;"
            strTemp=strTemp & "<a href='"&Url&"page="&(MyPage-1)&"'>上页</a>&nbsp;"
      end if

      if n-MyPage<1 then
            strTemp=strTemp & "下页 尾页"
      else
            strTemp=strTemp & "<a href='"&Url&"page="&(MyPage+1)&"'>下页</a>&nbsp;"
            strTemp=strTemp & "<a href='"&Url& "page="&n& "'>尾页</a>"
      end if
       strTemp=strTemp & "&nbsp;页次:<strong><font color=red>"&MyPage&"</font>/"&n&"</strong>页"
    strTemp=strTemp & "<b>"&MyPageSize&"</b>  名/页"
        strTemp=strTemp & "转到:<select name='page' size='1' onChange=""javascript:window.location='"&Url& "page=" & "'+this.options[this.selectedIndex].value;"" class='input'>"   
        for i = 1 to n   
            strTemp=strTemp & "<option value='"&i&"'"
            if cint(MyPage)=cint(i) then strTemp=strTemp & " selected "
            strTemp=strTemp & ">第" & i & "页</option>"   
        next
        strTemp=strTemp & "</select>"
    strTemp=strTemp & "</td></tr>"
    response.write strTemp
%>

[ 本帖最后由 wangjy500 于 2010-9-27 13:06 编辑 ]

QQ:63572063
2010-09-26 23:42
jingjing316
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:293
专家分:541
注 册:2009-8-11
得分:10 
我以前也遇到过这个情况,照着下面这个程序改的,你也研究一下吧
实例75.rar (157.08 KB)
2010-09-29 11:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-321133-1-1.html




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

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