asp全站搜索代码(asp搜索功能)
admin 发布:2022-12-19 18:15 133
本篇文章给大家谈谈asp全站搜索代码,以及asp搜索功能对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
ASP搜索代码
以下代码能同时筛选:区域、大类、小类、商品—商家(单选框)、关键字
(一),首先利用Access 2003建立一个名为list.mdb的数据库,在里面建立一个名为list的表,然后在list表里面输入一些你想要被查询的文件名字,关键的搜索词还有相对应的链接,下面建立了四个项目ID(编号),title(主题),word(关键词),url(链接地址),如下表所示:
ID title word url
1 cgi教程 本地调试cgi cgi/testcgi.htm
2 下载中心 聊天室,留言本 download/index.htm
(二),建立了数据库以后就可以建立你的asp搜索页面了,下面是一个文件名
为search.htm的asp搜索页面的源程序,这个搜索引擎可以同时搜索title和word里面的内容,当然如果你有需要的话可以建立更多的搜索:
!--#i nclude file="ADOVBS.inc"--
% "建立数据库的连接
con="DBQ="+server.mappath("list.mdb")+";DefaultDir=;DIRVER={microsoft Access Driver(*.mdb)};"
"建立CONNECTION对象并打开数据库
set mycon=server.createobject("ADODB.CONNECTION")
mycon.open.con %
"创建Recordset对象的例程,打开Recordset对象传递SQL串以及所有的
连接信息
% set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT*FORM list where title and word like ''%''
request.form("word")"%''",MyCon,adOpenStatie
%
"建立查询后的显示信息和查询页面,你想取什么名字都可以
htmlheadtitle查询结果/title/head
body bgcolor="#ffffff"
p align="center"br
"统计查询共有% Response.Write(RS.RecordCount) %条纪录/pbr
div align="center"center
table border="1" align="center"
bordercolor="000000" berdorcoorlight="#000000"
bordercolordark="#ffffff"
tr align="center"
td width="20%" align="center" bgcolor="#ffffff"ID/td
td width="60%" align="center" bgcolor="#ffffff"主题/td
td width="20%" align="center" bgcolor="#ffffff"查看/td/table
table border="1" align="center"
bordercolor="000000" berdorcoorlight="#000000"
bordercolordark="#ffffff"
tr align="center"
!--从数据库提取信息--
% while not rs.eof %
tr align="center"
td width="20%" align="center" bgcolor="#ffffff"% =rs("id") %/td
td width="60%" align="center" bgcolor="#ffffff"% =rs("title") %/td
td width="20%" align="center" bgcolor="#ffffff"a href="% =rs("url") %"GO/a/td
% rs.movenext %/tr % wend %/table/center/div% rs.close %
% mycon.close %
"关闭链接
/body/html
下面我们来建立搜索页面
htmlheadtitle搜索页面/title/head
!--创建搜索表格--
from method="POST" action="search.asp"
div align="center"centerpinput type="text" name="word" size="30"
input type="submit" ="提交" name="B1"input type="reset" ="清除" name="B2"/p
/center/div/form
hr width="600" align="center"
html
这样可以么?
asp搜索代码
什么都不输入,可以直接在JS端就判断提示,不用提交到服务器了
在服务器端,直接判断request("keyword")
如果为空就直接提示无相关产品然后response.end就行了
ASP站内搜索代码
%exec="select * from diannao"
if request("action")="seach" then
exec=exec" where [name] = '"request("names")"'" '精确搜索
exec=exec" where [name] leke '%"request("names")"%'" '模糊搜索
end if
exec=exec" order by id desc"%获取的俩种选一个
form method="post" action="" onSubmit="return checkmem(this)"
input type="hidden" name="action" value="seach" /
input type="text" name="names" id="names" /
input type="submit" name="button" id="button" value="搜 索" //formscript language="javascript"
function checkmem(form){
if (form.names.value==""){
alert('请填写搜索使用人的姓名');
form.names.focus();
return false;
}
}
/script这个是表单的
asp 搜索代码
你的问题是 ? 其实你不用这么麻烦 ,你直接这段就可以了:
%
Select Case request.Form("xz")
case "xz"
table="指定的表"
case "xw"
table="指定的表"
case "ly"
table="指定的表"
case "yy"
table="指定的表"
end select
Company = Request.Form("gjz")
set conn=server.CreateObject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="server.mappath("date\data.mdb")
set rs=server.createobject("adodb.recordset")
sql = "Select * From" table" where (内容 Like '%" Company "%')"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "没有找到相关信息!!"
else
Do while not rs.eof %
table width="100%" border="0"
tr
tddiv align="center"a href="player.asp?id=%=rs("id")%"%=rs("内容")%/a
/div/td
/tr
/table
%
rs.MoveNext
loop
end if
%
还有是你的搜索表最好附带一个参数来执行,要不可以通过其它页面注入表单值的 。 链接那可以规划好目录值与变量值对应来实现这一段代码。
asp站内搜索代码。怎么办?
"下边的代码是搜索完数据绑定到GridView。(注:wenku是数据库名,你可以改为自己的测试一下。)
string
sql
=
"select
count(*)
from
wenku
where
标题
like
'%'+'"
+
txtTitle.Text.Trim()+
"'+'%'";
SqlConnection
conn
=
new
SqlConnection();
conn.ConnectionString
=
ConfigurationManager.ConnectionStrings["connstr"].ToString();
SqlDataAdapter
sda
=
new
SqlDataAdapter(sql,
conn);
DataSet
ds
=
new
DataSet();
sda.Fill(ds,
"wenku");
GridView1.DataSource
=
ds.Tables[0].DefaultView;
GridView1.DataBind();
try
{
conn.Open();
}
catch
(Exception
ex)
{
labMessage.Text
=
ex.Message.ToString();
}
finally
{
ds.Dispose();
sda.Dispose();
conn.Close();
conn.Dispose();
}"
asp站内搜索代码
下面的代码是搜索完数据绑定到GridView。(注:wenku是数据库名,你可以改为自己的测试一下。)
string sql = "select count(*) from wenku where 标题 like '%'+'" + txtTitle.Text.Trim()+ "'+'%'";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["connstr"].ToString();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
sda.Fill(ds, "wenku");
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
try
{
conn.Open();
}
catch (Exception ex)
{
labMessage.Text = ex.Message.ToString();
}
finally
{
ds.Dispose();
sda.Dispose();
conn.Close();
conn.Dispose();
}
关于asp全站搜索代码和asp搜索功能的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:关于editplus代码提示插件的信息
- 下一篇:js网页弹窗代码(jsp弹窗代码)
相关推荐
- 05-04sql超市商品信息视图代码的简单介绍[20240504更新]
- 05-04淘宝静态全屏海报代码(淘宝页头全屏代码)[20240504更新]
- 05-04图片放大代码(图片放大代码怎么做)[20240504更新]
- 05-04点击按钮保存网页代码(html保存按钮)[20240504更新]
- 05-04html放大代码(HTML放大)[20240504更新]
- 05-04js页面全屏代码(js移动端全屏)[20240504更新]
- 05-04vc图像处理代码(vc图像处理代码是什么)[20240504更新]
- 05-04文件类别代码(文件类别代码QM)[20240504更新]
- 05-04vb.net代码入门(vb·net)[20240504更新]
- 05-04文字框代码怎么写(html文字框代码)[20240504更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接