| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1026 人关注过本帖
标题:三个下拉表单和关键字and起来 的问题
取消只看楼主 加入收藏
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
 问题点数:0 回复次数:7 
三个下拉表单和关键字and起来 的问题
typeid、chanye和touzhi分别是三个下拉表单,keyword是关键字

Set rs= Server.CreateObject ("ADODB.RecordSet")
if typeid<>"b" and chanye<>"a" and touzhi<>"c" and keyword<>"" then
sql = "select * from goods where typeid='"&typeid&"'and touzhi='"&touzhi&"' and chanye='"&chanye&"' and typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye="a" and keyword="" and touzhi="c" then
sql = 这里该怎么写?????????????????????
elseif typeid="b" and chanye="a" and keyword<>"" and touzhi="c" then
sql = "select * from goods where typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye<>"a" and keyword="" and touzhi="c"then
sql = "select * from goods where chanye='"&chanye&"'"
elseif typeid<>"b" and chanye="a" and keyword="" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'"
elseif typeid="b" and chanye="a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye<>"a" and keyword="" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'and chanye='"&chanye&"'"
elseif typeid<>"b" and chanye="a" and keyword<>"" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'and typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye<>"a" and keyword<>"" and touzhi="c"then
sql = "select * from goods where chanye='"&chanye&"' and typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye="a" and keyword<>"" and touzhi<>"c"then
sql = "select * from goods where typeid1 like '%"&keyword&"%' and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye="a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where typeid='"&typeid&"'and touzhi='"&touzhi&"'"
elseif typeid="b" and chanye<>"a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where chanye='"&chanye&"'and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye<>"a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where typeid='"&typeid&"'and chanye='"&chanye&"' and touzhi='"&touzhi&"'"
elseif typeid="b" and chanye<>"a" and keyword<>"" and touzhi<>"c"then
sql = "select * from goods where chanye='"&chanye&"' and typeid1 like '%"&keyword&"%' and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye="a" and keyword<>"" and touzhi<>"c"then
sql = "select * from goods where typeid='"&typeid&"'and typeid1 like '%"&keyword&"%' and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye<>"a" and keyword<>"" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'and chanye='"&chanye&"' and typeid1 like '%"&keyword&"%'"
end if
搜索更多相关主题的帖子: 表单 关键 
2005-11-28 09:01
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
呵呵,不用看完的,就看这句就行了
elseif typeid="b" and chanye="a" and keyword="" and touzhi="c" then
sql = 这里该怎么写?????????????????????

这里
typeid="b" chanye="a" touzhi="c" keyword=""就是不选的意思,

if I=pig and I drop off that I no dread boiled water scald end if
2005-11-28 09:58
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
说的好。
我是笨鸟用笨办法,呵呵

if I=pig and I drop off that I no dread boiled water scald end if
2005-11-28 09:59
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
那你们平时把三个同级的表单and起来做搜索用什么语句?

if I=pig and I drop off that I no dread boiled water scald end if
2005-11-28 10:00
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
我试了。三个表单全选或只选其中一个,没有问题,搜出来的条件都是对的

但要都不选(也就是全部搜索),就出现bug了。


if I=pig and I drop off that I no dread boiled water scald end if
2005-11-28 10:29
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
好的,谢谢,说也说不清,我把传到网上你看看。
主要有两大问题,我把源码也传上了,你有空下载帮搞一下。
一、三个表单和关键字都不选时,搜索会出错
二、第一个表单不选,选其他表单,如果结果有两页以上,那么点下页时也会出错,(比如第二个表单的“畜产品加工业”这个就有两页,点下一页就会出错)。

演示页面 www.zh-expo.com/asp4

源文件 www.zh-expo.com/asp4/so.rar

数据库在 www.zh-exp.com/asp4/mhd77/cg988.mdb

if I=pig and I drop off that I no dread boiled water scald end if
2005-11-28 11:09
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 

改了,,出错。。。可能我改错地方了。。。我把我搜索页的源码放出来。

<!-- #Include File=Conn.asp -->
<!-- #Include File=setup.asp -->
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
<style fprolloverstyle>a:hover { color: #FF0000 }
</style>
</head>

<%Set rst= Server.CreateObject ("ADODB.RecordSet")
sql = "select * from type"
rst.open sql,conn,1,3
%>
<!--#include file="head.asp"-->
<%
'-------------------------------------------
typeid=request("typeid") 第一个表单
chanye=request("chanye") 第二个表单
touzhi=request("touzhi") 第三个表单
keyword=trim(request("typeid1")) 关键字

dim sql,typeid
dim rs '实例
dim totalPut '总记录数
dim CurrentPage '当前页
dim TotalPages '总页数
dim i,j

if keyword="关键字可以不输入" then
keyword=""
else
findword="typeid1 like '%"&keyword&"%' "
end if
Set rs= Server.CreateObject ("ADODB.RecordSet")
if typeid<>"b" and chanye<>"a" and touzhi<>"c" and keyword<>"" then
sql = "select * from goods where typeid='"&typeid&"'and touzhi='"&touzhi&"' and chanye='"&chanye&"' and typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye="a" and keyword<>"" and touzhi="c" then
sql = "select * from goods where typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye<>"a" and keyword="" and touzhi="c"then
sql = "select * from goods where chanye='"&chanye&"'"
elseif typeid<>"b" and chanye="a" and keyword="" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'"
elseif typeid="b" and chanye="a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye<>"a" and keyword="" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'and chanye='"&chanye&"'"
elseif typeid<>"b" and chanye="a" and keyword<>"" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'and typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye<>"a" and keyword<>"" and touzhi="c"then
sql = "select * from goods where chanye='"&chanye&"' and typeid1 like '%"&keyword&"%'"
elseif typeid="b" and chanye="a" and keyword<>"" and touzhi<>"c"then
sql = "select * from goods where typeid1 like '%"&keyword&"%' and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye="a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where typeid='"&typeid&"'and touzhi='"&touzhi&"'"
elseif typeid="b" and chanye<>"a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where chanye='"&chanye&"'and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye<>"a" and keyword="" and touzhi<>"c"then
sql = "select * from goods where typeid='"&typeid&"'and chanye='"&chanye&"' and touzhi='"&touzhi&"'"
elseif typeid="b" and chanye<>"a" and keyword<>"" and touzhi<>"c"then
sql = "select * from goods where chanye='"&chanye&"' and typeid1 like '%"&keyword&"%' and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye="a" and keyword<>"" and touzhi<>"c"then
sql = "select * from goods where typeid='"&typeid&"'and typeid1 like '%"&keyword&"%' and touzhi='"&touzhi&"'"
elseif typeid<>"b" and chanye<>"a" and keyword<>"" and touzhi="c"then
sql = "select * from goods where typeid='"&typeid&"'and chanye='"&chanye&"' and typeid1 like '%"&keyword&"%'"
end if

rs.open sql,conn,1,3

'----------------------------------
if rs.bof then
response.write " <br><br><br><br>"
response.write "<p align='center'> 没有物品 !</p>"
response.end
end if
rs.MoveFirst '到第一条记录
rs.pagesize=MaxPerPage '定义每页记录数
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write " <br><br><br><br>"
response.write "<p align='center'> 没有物品 !</p>"
response.end
else
totalPut=rs.recordcount 'totalput=总记录数
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage < totalPut then
rs.move(currentPage-1)*MaxPerPage
end if
end if
end if
%>
<body topmargin="1" leftmargin="1" link="#000000" vlink="#000000">

<table border="0" cellpadding="0" cellspacing="0" width="60%" align="center">
<tr>
<td width="100"><img src="image/home.gif" width="16" height="16">
<a href="index.asp">回首页</a></td>
<td width="411" valign="bottom">
<%
if rs.pagecount <= 6 then
for j=1 to rs.pagecount
response.write "[<a href='index.asp?typeid="&typeid&"&page="&j&"'>"&j&"</a>]"
next
else
for j=1 to 8
response.write "[<a href='index.asp?typeid="&typeid&"&page="&j&"'>"&j&"</a>]&nbsp;"
next
response.write "[<a href='index.asp?typeid="&typeid&"&page="&rs.pagecount&"' title='最后一页'>&gt;&gt;</a>]"
end if
%> </td>
<td width="291">
<p align="right">
<img border="0" src="image/inboxno.gif" width="16" height="16">页数:<%=CurrentPage%>/<%=rs.pagecount%>&nbsp;&nbsp;&nbsp;<img border="0" src="image/jinghua.gif" width="13" height="16">&nbsp;项目数量:&nbsp;<%=totalPut%></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="1" width="60%" align="center" height="80" bgcolor="#BB0B48">
<tr align="center">
<td class="td1" height="20" width="81" bgcolor="#00659C" align="center">
<p align="center"><font color="#FFFFFF">地区</font></td>
<td class="td1" height="20" width="81" bgcolor="#00659C" align="center">
<font color="#FFFFFF">省份</font></td>
<td class="td1" height="20" width="334" bgcolor="#00659C" align="center">
<font color="#FFFFFF">项目名称</font></td>
<td class="td1" height="20" width="145" bgcolor="#00659C" align="center">
<font color="#FFFFFF">行业</font></td>
<td class="td1" height="20" width="75" bgcolor="#00659C" align="center">
<font color="#FFFFFF">所属产业</font></td>
<td class="td1" height="20" width="65" bgcolor="#00659C" align="center">
<font color="#FFFFFF">投资总额</font></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td width="116" align="center" bgcolor="#FFF3EE" height="18"><%=rs("typeid")%></td>
<td width="100" align="center" bgcolor="#FFF3EE" height="18"><%=rs("name")%></td>
<td width="334" align="center" bgcolor="#FFF3EE" height="18"><a href="list.asp?id=<%=rs("id")%>" target="_blank"><%=rs("typeid1")%></a></td>
<td width="75" align="center" bgcolor="#FFF3EE" height="18"><%=rs("money")%></td>
<td width="65" align="center" bgcolor="#FFF3EE" height="18"><%=rs("chanye")%></td>
<td width="170" align="center" bgcolor="#FFF3EE" height="18"><%=rs("time")%></td>
</tr>
<tr>
<td width="746" colspan="7" bgcolor="#FFF3EE" height="18">
<img border="0" src="image/inboxnonew.gif" width="16" height="16"><%=rs("hownew")%></td>
</tr>
<tr>
<td width="746" colspan="7" height="16" bgcolor="#FFFFFF"> </td>
</tr>
<%i=i+1
if i>=25 then exit do
rs.movenext
loop
%>
</table>
<table border="0" cellspacing="1" width="60%" align="center">
<tr>
<td class="td1" bgcolor="#00659C" width="100%">
<div align="right">
<select size="1" name="D1" onchange="MM_goToURL('parent',this.value);return document.MM_returnValue">
<option>跳转页数</option>
<%
soonhost=0
DO WHILE NOT soonhost = rs.pageCount %>
<option value="view.asp?Page=<% =soonhost+1 %>"><% =soonhost+1 %></option>
<% soonhost=soonhost+1
loop
%></select>  
<%
dim n,k
if (totalPut mod MaxPerPage)=0 then 'n表示总页数
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
k=currentPage
if k<>1 then
response.write "<b>"+"<a href='index.asp?page=1'><font color=""#FFFFFF"">[首页]</font></a></b> "
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(k-1)+"'><font color=""#FFFFFF"">[上一页]</font></a></b> "
else
Response.Write "<font color=""#FFFFFF"">[首页] [上一页]</font>"
end if
if k<>n then
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(k+1)+"'><font color=""#FFFFFF"">[下一页]</font></a></b> "
response.write "<b>"+"<a href='index.asp?typeid="+typeid+"&page="+cstr(n)+"'><font color=""#FFFFFF"">[尾页]</font></a></b> "
else
Response.Write "<font color=""#FFFFFF"">[下一页] [尾页]</font>"
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</div>
</td>
</tr>
</table>
<p><br>
</p>
</body>

</html>


if I=pig and I drop off that I no dread boiled water scald end if
2005-11-28 11:32
a4620269
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-11-23
收藏
得分:0 
有没有人帮忙改一下啊?
源程序很小的。谢谢了

if I=pig and I drop off that I no dread boiled water scald end if
2005-11-28 14:15
快速回复:三个下拉表单和关键字and起来 的问题
数据加载中...
 
   



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

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