搜索
两个页面,seach1.asp和seach2.asp,数据库有news的表,有id,title等字段。我就想做一个可以搜索标题关键字的东西。
seach1.asp 的内容如下:
--------------------------------------
<form action="seach2.asp" method="post" name="form">
<input type="text" name="key" id="key">
<input type="submit" name="submit" value="搜索">
</form>
-------------------------------
seach2.asp的内容如下:
------------------------------
<!--#include file="conn.asp"-->
<%
key=request.form("key")
sql="select * from news where title like '%key%'"
set rs=db.execute(sql)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table>
<% do while not rs.eof%>
<tr>
<td>
<%=rs("title")%>
</td>
</tr>
<%
rs.movenext
loop
%>
</table>
</body>
</html>
----------------------------
conn.asp的内容如下:
--------------------------
<%
set db=server.CreateObject("adodb.connection")
db.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("data/data.mdb")
%>
------------------------------------
我在seach1.asp上输入关键字后点击搜索出现seach2.asp,但是什么内容都没有,
有人告诉我说sql="select * from news where title like '%key%'"的'%key%'改为'*key*'
请问他们有什么区别