| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 476 人关注过本帖
标题:[求助]搜索问题
只看楼主 加入收藏
mai_25
Rank: 3Rank: 3
来 自:上海
等 级:论坛游侠
帖 子:206
专家分:131
注 册:2006-7-22
结帖率:65.22%
收藏
 问题点数:0 回复次数:2 
[求助]搜索问题
这是搜索面页代码:<form action="search.asp?title=search" method="post" name="form1" target="_blank">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">关键字搜索:</td>
<td align="center"><input name="tit" type="text" id="tit" size="15"></td>
<td align="center">信息种类:</td>
<td align="center"><select name="typ" id="typ">
<option value="" selected>不限</option>
<option value="1">游客求购</option>
<option value="2">旅行社求购</option>
<option value="3">酒店求购</option>
<option value="4">车队求购</option>
<option value="5">景点求购</option>
<option value="6">散客线路</option>
<option value="7">同行报价</option>
<option value="8">折扣酒店</option>
<option value="9">特价票务</option>
<option value="10">车辆供应</option>
<option value="11">优惠门票</option>
<option value="12">工艺品出售</option>
<option value="13">求职信息</option>
<option value="14">招聘信息</option>
</select></td>
<td align="center"><input type="submit" value="开始搜索"></td>
</tr>
</table>
</td></form>



下面是搜索结果:<%
if Request.QueryString("title")="search" Then
if Request.form("typ")="1" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ2 = '2' and send ='杭州' and audi = '是' and dat > date()-val and typ1='9' order by id desc"
elseif Request.form("typ")="2" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ2 = '2' and send ='杭州' and audi = '是' and dat > date()-val and (typ1='2') order by id desc"
elseif Request.form("typ")="3" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ2 = '2' and send ='杭州' and audi = '是' and dat > date()-val and (typ1='4') order by id desc"
elseif Request.form("typ")="4" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ2 = '2' and send ='杭州' and audi = '是' and dat > date()-val and (typ1='26') order by id desc"
elseif Request.form("typ")="5" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ2 = '2' and send ='杭州' and audi = '是' and dat > date()-val and (typ1='3') order by id desc"
elseif Request.form("typ")="6" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ4 = '5' and typ2 = '1' and send ='杭州' and audi = '是' and dat > date()-val and typ1='2' and (typ3 like '%9%' or typ3 like '%1%') order by id desc"
elseif Request.form("typ")="7" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ4 = '5' and typ2 = '1' and send ='杭州' and audi = '是' and dat > date()-val and typ1='2' and typ3 like '%2%' order by id desc"
elseif Request.form("typ")="8" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ4 = '3' and send ='杭州' and audi = '是' and dat > date()-val order by id desc"
elseif Request.form("typ")="9" Then
exec="select * from info where tit like '"&request.form("tit")&"' (typ4 = '7' or typ4 = '8' or typ4 = '9') and typ2 = '1' and audi = '是' and dat > date()-val and send='杭州' order by id desc"
elseif Request.form("typ")="10" Then
exec="select * from info where tit like '"&request.form("tit")&"' send='杭州' and typ2 = '1' and audi = '是' and dat > date()-val and typ1='1' order by id desc"
elseif Request.form("typ")="11" Then
exec="select * from info where tit like '"&request.form("tit")&"' send='杭州' and typ2 = '1' and audi = '是' and dat > date()-val and typ1='4' order by id desc"
elseif Request.form("typ")="12" Then
exec="select * from info where tit like '"&request.form("tit")&"' typ4 = '2' and typ2 = '1' and audi = '是' and dat > date()-val and send='杭州' and thj='商务礼品' order by id desc"
elseif Request.form("typ")="13" Then
exec="select * from info where tit like '"&request.form("tit")&"' send='杭州' and typ2 = '4' and audi = '是' and dat > date()-val order by id desc"
elseif Request.form("typ")="14" Then
exec="select * from info where tit like '"&request.form("tit")&"' send='杭州' and typ2 = '3' and audi = '是' and dat > date()-val order by id desc"
end if
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
rs.PageSize=20
pagecount=rs.PageCount
page=int(request.QueryString ("page"))
if page<=0 then page=1
if request.QueryString("page")="" then
page=1
end if
if not rs.eof then rs.AbsolutePage=page
%>

请问这个搜索结果有什么问题吗?请各位快帮帮忙。
搜索更多相关主题的帖子: 搜索 
2006-08-24 18:03
google
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:22
帖 子:3419
专家分:23
注 册:2005-11-1
收藏
得分:0 
太多了
我一般用合成SQL语句,并结合SESSION来做复合搜索

祝天下所有母亲幸福安康!~
2006-08-24 22:43
渚薰
Rank: 6Rank: 6
等 级:贵宾
威 望:22
帖 子:1132
专家分:0
注 册:2006-8-6
收藏
得分:0 
楼主可不可以把那么多if elseif改成select case啊……
而且看了你的搜索代码,感觉你的数据库设计有很大问题,而且编程思路也不够清晰……
可能语重了,但是真诚希望楼主学习好一门计算机语言

[此贴子已经被作者于2006-8-25 14:46:10编辑过]


个人ajax技术专题站: " target="_blank">http://www. 我不会闲你烦,只会闲你不够烦!
2006-08-25 14:44
快速回复:[求助]搜索问题
数据加载中...
 
   



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

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