电动机选择表:asp搜索引擎的制作

来源:百度文库 编辑:高校问答 时间:2024/04/29 21:02:40
偶想用写ASP搜索引擎,数据文件是.MDB格式的.数据库名字是#DB1.ASP
数据库里有几张表,偶想调用news表.表里有几个小表,有id(定义为编号)、title(文章具体标题)、content(文章具体内容)、time(发布文章的时间)、hit(点击次数)叙述完毕。
偶想做个搜索引擎,搜索引擎包含几种搜索功能,其中包括按时间搜索、按具体内容搜索、按标题搜索、按点击次数搜索。
俺已经发好几条信息了,希望有能力的大哥给俺详细说说,或者将具体的代码告诉俺。别只说一章半节的。

搜索引擎包含几种搜索功能...........

这样是叫几种吗??

表单文件
一个文本框text(Name=Key)
一个select(Name=KeyClass) 其中包括
值 内容
1 按具体内容
2 按时间
3 按标题
4 按点击次数

搜索文件
<%
.........打开数据库 conn
.........建立对像 rs

dim Key,KeyClass
Key=request.Form("Key")
KeyClass=request.Form("KeyClass")

If KeyClass=1 then
sql="select *from news where content like '%"&Key&"%'"
ElseIf Keyclass=2 then
sql="select *from news where time='"&Key&"'"
ElseIf Keyclass=3 then
sql="select *from news where title like '%"&Key&"%'"
ElseIf Keyclass=4 then
sql="select *from news where hit="&Key
End if

rs.open sql,conn,1,3
..........输出

%>

根据传递过来的参数决定查询SQL语句,
SearchType
值 说明
1 按时间
2 按内容
3 按标题

st = Cint(Request("SearchType"))
'下面的需要进行注入过滤
ti = Request("time")
co = Request("Content")
title = Request("title")
Sql = "Select * from news where 1 = 1 "
if st = 1 and isdate(ti) then
Sql = Sql&" and time=#"&ti&"#"
elseif st = 2 then
Sql = Sql&" and content like '%"&co&"%'"
elseif st = 3 then
Sql = Sql&" and title like '%"&title&"%'"
end if

所有其他的搜索与上面的类似

对内容的搜索不太现实,建议使用 key来代替
对一个新闻多加一个key项,