站内搜索代码问题?

表单代码:<formaction="search.asp"method="get"name="form1"><imgsrc="images_3/kso.gif"width... 表单代码:<form action="search.asp" method="get" name="form1" ><img src="images_3/kso.gif" width="102" height="18" />
<input name="key" type="text" class="form" size="25" />
<input type="radio" name="radiobutton" value="radiobutton1" />学校名称
<input type="radio" name="radiobutton" value="radiobutton2" />参赛选手
<input type="radio" name="radiobutton" value="radiobutton3"/>宝贝名称
<input type="submit" name="submit" value="提交搜索"/>
</form>
search.asp代码
<%
radiobutton=request.form("radiobutton")
key=request.form("key")
%>
<%
select case radiobutton
case "radiobutton1"
sql = "Select * From c Where school like '%"&key&"%' "
case "radiobutton2"
sql = "Select * From c Where player like '%"&key&"%' "
case "radiobutton3"
sql = "Select * From c Where product like '%"&key&"%' "
end select
dim key,conn,rs,sql
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<html>
<head>
<title>搜索结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
%><tr>
<td><%=rs("school")%></td>
<td><%=rs("player")%></td>
<td><%=rs("product")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
</body>
</html>
怎么搜索不到啊?请高手解释?!
access数据库里边,表名c,字段school,player,product。
sql = "Select * From c Where school="东北大学""是能够显示的。
展开
 我来答
张小刚爱生活
2009-07-30 · TA获得超过1025个赞
知道大有可为答主
回答量:2140
采纳率:100%
帮助的人:547万
展开全部
表单代码:
<form action="search.asp" method="post" name="form1" ><img src="images_3/kso.gif" width="102" height="18" />
<input name="key" type="text" class="form" size="25" />
<input type="radio" name="radiobutton" value="radiobutton1" />学校名称
<input type="radio" name="radiobutton" value="radiobutton2" />参赛选手
<input type="radio" name="radiobutton" value="radiobutton3"/>宝贝名称
<input type="submit" name="submit" value="提交搜索"/>
</form>

search.asp代码
<%
dim key,conn,rs,sql
radiobutton=request.form("radiobutton")
key=request.form("key")
if key = "" then
response.write "请输入关键字!"
response.end
end if
select case radiobutton
case "radiobutton1"
sql = "Select * From c Where school like '%"&key&"%'"
case "radiobutton2"
sql = "Select * From c Where player like '%"&key&"%'"
case "radiobutton3"
sql = "Select * From c Where product like '%"&key&"%'"
case else
sql = "Select * From c Where school like '%"&key&"%'"
end select
response.write sql & "<br>"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<html>
<head>
<title>搜索结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
%><tr>
<td><%=rs("school")%></td>
<td><%=rs("player")%></td>
<td><%=rs("product")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
</body>
</html>

答案已修改
表单提交方式是get ,request.form("key") 取值就有问题
隋理位成双
2013-04-19 · TA获得超过3922个赞
知道大有可为答主
回答量:3150
采纳率:29%
帮助的人:155万
展开全部
<!--#include
file="conn.asp"-->
<%
word=request.form("word")'表单里的值
set
rs=server.CreateObject("adodb.recordset")
sql
=
"select
*
from
sheet1
where
[字段]
like
'%"&word&"%'
rs.open
sql
,conn
,1
,3
%>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式