if ...
sql =...
elseif ...
sql =
elseif ...
sql =...
如此这样,然后进行分页时如何把sql传进去呢?
<a href="search.asp?page=<%=currentpage+1%>想在这把sql插进来,不知道思路是否正确">下一页</a>
ps:不把sql传进来,搜索时是正确的,点击下一页,上一页等链接时会出错,请问应该如何设置呢?
[此贴子已经被作者于2007-5-22 20:20:02编辑过]
[此贴子已经被作者于2007-5-22 20:20:02编辑过]
<%
Dim SearchStr
SearchStr = ""
If KeyWord1 <> "" Then
    Sql = ...
    SearchStr = SearchStr  &"&KeyWord1="& KeyWord1 
ElseIf  KeyWord2 <> "" Then
    Sql = ...
    SearchStr = SearchStr  &"&KeyWord2="& KeyWord2
...
End IF
%>
<a href="search.asp?page=<%=currentpage+1%><%=SearchStr%>想在这把sql插进来,不知道思路是否正确">下一页</a>

这个是我以前写的一个 不知道你能不能用 我这个是2个列表 一个关键字的,比较简单的.
<!--#include file="conn.inc"-->
<!--#Include file="admin/adovbs.inc"-->
<%
rs3.open "select * from p_class where l_id=2 order by id asc",conn,1,1
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>-=济南雅致泰克电子有限公司=-</title>
<link href="css.css" rel="stylesheet" type="text/css">
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0
        do while not rs3.eof 
        %>
subcat[<%=count%>] = new Array("<%=rs3("c_types")%>","<%=rs3("c_name")%>","<%=rs3("id")%>");
        <%
        count = count + 1
        rs3.movenext
        loop
        rs3.close
        %>
onecount=<%=count%>;
function changelocation(locationid)
    {
    
    document.form1.ctypes.length = 0; 
 //window.alert(locationid);
    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
                document.form1.ctypes.options[document.form1.ctypes.length] = new Option(subcat[i][0], subcat[i][0]);
                //window.alert("aa");
            }        
        }
        
    }    
    
</script>
</head>
<body>
<table width="1000"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><!--#include file="top.asp"--></td>
  </tr>
</table>
<table width="1000" height="124" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="124" align="center" valign="top">      <table width="1000" height="302" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="23%" valign="top"><table width="100%" height="78"  border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td><img src="images/index_r4_c1.jpg" width="233" height="53"></td>
              </tr>
              <tr>
                <td height="178" align="left" valign="top" background="images/index_r5_c1.jpg"><div align="center">
                  <table width="93%"  border="0" cellspacing="0" cellpadding="0">
           <%
           sql="select * from gqgx where notice=true Order By id desc"
                set rs2=conn.execute(sql) 
                if rs2.eof or rs2.bof then
                else
                for i=1 to 11
                id=rs2("id")
                title=rs2("title")
                titl=left(title,16)
                  response.Write("<tr>")
                    response.Write("<td align=left><A href=gqxxs.asp?id="&id&" target=_blank title="&title&">"&titl&"</a></td>")
                 response.Write(" </tr>")
                 rs2.movenext
                 if rs2.eof or rs2.bof then exit for
                 next
                 end if
                 %>
                    
                  
                      <tr>
                      <td><div align="right"><a href="gqxx.asp">更多>></a> </div></td>
                    </tr>
                  </table>
                </div></td>
              </tr>
            </table>
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><img src="images/index_r4_c3.jpg" width="233" height="61"></td>
                </tr>
                <tr>
                  <td height="160" align="center" valign="top" background="images/index_r8_c1.jpg"><div align="center">
                      <form name="form1" method="post" action="prods.asp">
                        产品类别:
                 <select name="classid" id="classid" class="unnamed1" onChange="changelocation(document.form1.classid.options[document.form1.classid.selectedIndex].value)">
                            <option value="0" selected>↓选择类别↓</option>
              <% sql="select * from p_class where l_id=1"
                set rs1=conn.Execute (sql) %>
                   <%dim cj
                  do while not rs1.EOF 
                  id=rs1("id")
                  c_name=rs1("c_name")
            response.Write("<option value="&c_name&">"&c_name&"</option>")
            %>
                   <%
        rs1.MoveNext
          loop 
          rs1.close
          set rs1=nothing
          %>
  
                      </select>
                        <br>
                        <br>
                        分  类:
                     <select name="ctypes" id="ctypes" class="unnamed1">
                          <option value="0" selected>↓选择类别↓</option>
                        </select>
                        <br>
                        <br>
                        产品名称:
                        <input name="pname" type="text" class="unnamed2" id="pname">
                        <br>
                        <br>
                        <input type="submit" name="Submit" value="提交">  
                        <input type="reset" name="Submit2" value="重置">
                      </form>
                  </div></td>
                </tr>
              </table></td>
            <td width="77%" valign="top"><table width="100%" height="450"  border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="59"><img src="images/chanpin.jpg" width="765" height="59"></td>
              </tr>
              <tr>
                <td height="361" align="left" valign="top">
                
                <br><%
                if request("classid")="0" then
                pname=request("pname")
                str="select * from prod where title like '%"&pname&"%' Order By id desc"
                a="&classid=0&pname="&pname
                elseif request("pname")<>"" or request("classid")<>"0" then
                pname=request("pname")
                classid=request("classid")
                ctypes=request("ctypes")
                str="select * from prod where title like '%"&pname&"%' and c_name='"&classid&"' and c_types='"&ctypes&"' Order By id desc"
                a="&classid="&classid&"&ctypes="&ctypes&"&pname="&pname
                else
                str="select * from prod Order By id desc"
                a=""
                end if
                rs.cursortype=3
                 rs.open str,conn,3,1
                if rs.eof or rs.bof then
                   response.write "没有信息记录"
                else  
                   rs.pagesize=8 
                   nums=rs.pagecount
          
                   i=0  
                  if request("page")="" then
                      page=1
                  else
                      page=CLng(request("page"))
                 end if
 
               IF page<1 Then
                   page=1
               end if
               If page>nums Then 
                  page=nums
                  rs.absolutepage=page
               end if
                  rs.absolutepage=cint(page)%>
       <table width="90%" height="258" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <% do while not rs.eof%>
                
                  <td height="125" align="left" valign="top">
                      <table width="360" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="ffffff">
                        <tr>
                          <td width="360" height="190" align="center" valign="middle" background="images/pbg.jpg">
                              <% if trim(rs("photo"))<>"" then %>
                              <img src=admin/<% = trim(rs("photo"))%> width="320" height="160"  border=0 >
                              <%  else %>                                
                              <img src=images/emptybook.jpg  border=0 >
                                  <% end if %></td>
                        </tr>
                        <tr>
                          <td height="20" align="center"><a href=productwz.asp?id=<%=rs("id")%> target="_blank"><%=rs("title")%></a> </td>
                        </tr>
                      </table>
                </td>
                  <%
            i=i+1
            if i mod 2=0 then response.write("</tr><tr>")
            if i>=8 then Exit Do
            rs.movenext
            loop
            rs.close
            set rs=nothing
            end if
            %>
                </tr>
            </table>
                <br>
                  <table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td height="20"><div align="center">
                        <table width="330" border="0" align="center" bgcolor="#FFFFFF">
                          <tr>
                            <%
  '翻页控制代码
  IF page<>1 Then
    Response.Write("<td><a href=prods.asp?page=1"&a&"><font color=000000>第一页</font></a></td>")
Response.Write("<td><a href=prods.asp?page="&(page-1)&""&a&"><font color=000000>上一页</font></a></td>")
  Else
    Response.Write("<td>第一页</td>")
Response.Write("<td>上一页</td>")
  End IF    
  IF page<>nums then
    Response.Write("<td><a href=prods.asp?page=" & (page+1) & ""&a&"><font color=000000>下一页</font></a></td>")
Response.Write("<td><a href=prods.asp?page=" & nums & ""&a&"><font color=000000>最后一页</font></a></td>")
  Else
    Response.Write("<td>下一页</td>")
Response.Write("<td>最后一页</td>")  
  End IF
  %>
                            <td><span class=style22>共<%=nums%>页</span></td>
                            <td align="left"><span class=style22>当前第<%=page%>页</span></td>
                          </tr>
                        </table>
                      </div></td>
                    </tr>
                  </table>
                  <br>
                </td>
              </tr>
            </table></td>
          </tr>
    </table></td></tr>
</table>
<table width="1000"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><!--#include file="bon.asp"--></td>
  </tr>
</table>
</body>
</html>
