请高手分析asp搜索代码

来源:百度知道 编辑:UC知道 时间:2024/05/09 20:29:16
<!-- #include file="config/db.asp" -->
<!-- #include file="config/function.inc.asp" -->
<%
word=Replace(request("keyword"), "'", "''")
Set rs = Server.CreateObject("ADODB.Recordset")
if word="" then
sql="select * from tbl_news where n_title like '%"& word &"%'"
else
response.write("没有搜索到你要的内容")
end if
%>
帮分析下这段的错误在哪里 提交代码如果方便也顺便帮写下 实现结果为用模糊查询tbl_news表下的n_title字段的值 有则显示(带链接更好) 无则提示 还有些分全贡献了 先谢谢了
muqiao520的 能再详细些吗 加上搜索的那部分 实现能搜出来结果 现在看上去怎么都是 请输入关键字 实现不了搜索的功能 谢谢了 如果谁有现成的模糊查询全代码带数据库的那种也可以access的 发到我邮箱:gengkuaishou1@163.com

<!-- #include file="config/db.asp" -->
<!-- #include file="config/function.inc.asp" -->
<%
word=Replace(request("keyword"), "'", "’")
Set rs = Server.CreateObject("ADODB.Recordset")
if word<>"" then
sql="select * from tbl_news where n_title like '%"& word &"%'"
rs.open sql,conn,1,3
if not rs.eof then
do while not rs.eof
'输入结果.
response.write rs("title") & "<br>"
rs.movenext
loop
else
response.write("没有搜索到你要的内容")
end if
rs.close
else
response.write "请输入搜索关键字."
end if
%>
以上代码中,conn为你的数据库连接.

如果总是说:请输入关键字,说明你这句:
word=Replace(request("keyword"), "'", "''")
可能没有得到上一程序提交的输入内容.

你上个网页应该是一个表单,表单里应该有个输入框,名称为keyword.