<title>Www.ttasp.net(Search Within Search Results)</title>
<body bgcolor="#FFFFFF">
<%
u_search=request.form("u_search")
u_prev_search=request.form("u_prev_search")
u_search_within=request.form("u_search_within")
检查看用户是否输入调查的内容
if u_search <> "" then
如果用户输入搜索和最初的搜索功能
和当前搜索等同的prev_搜索
if u_prev_search = "" then
u_prev_search=u_search
else
如果用户输入了搜索预先功能,然后添加到prev_搜索
u_prev_search=u_prev_search &","& u_search
如果有预先的搜索功能,那把u_ 搜索分开成列
g_prev_search=split(u_prev_search,",")
num_inputted=ubound(g_prev_search)
end if
sql= "select * from states where (capital like '%%"& u_search & "%%') "
检查看用户是否要求通过给新搜索的sql附加预先搜索功能来得到预先搜索的结果
if u_search_within = "Yes" then
for counter =0 to num_inputted-1
sql=sql& "and (capital like '%%"& g_prev_search(counter) & "%%') "
next
end if ' end the search within a search
accessdb="state_info"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, cn
如果没有找到记录显示发现没有记录
if rs.eof then
%>
No records were found
<%' if records are found display them
else
rs.movefirst
do while Not rs.eof
%>
<%= rs("capital") %><br>
<%
rs.movenext
loop
end if ' end of check for records
end if ' end the check for a user inputted value
%>
<!-- Begin Form Input Area -->
<form action="<%= request.servervariables("script_name") %>" method="post">
<input type="text" name="u_search" value="<%= u_search %>">
<br>
<%'Checks to see if the user has submitted a search request
如果是这样的话那么显示搜索或者从结果搜索的选项
if u_search <> "" then %>
<input type = "radio" name="u_search_within" checked value="No"> Search
<input type = "radio" name="u_search_within" value="Yes"> Search within results
<%' if the user indicates a search within results then add the surrent search to all previous
if u_search_within = "Yes" then %>
<input type = "hidden" name="u_prev_search" value="<%= u_prev_search %>">
<%'if the user is not searching within results make the prev_search eqaul to u_search
else %>
<input type = "hidden" name="u_prev_search" value="<%= u_search %>">
<% end if ' end check of search within a search %>
<br>
<% end if ' end check of of first search %>
<input type="submit" value="Search">
</form>
<!-- End Form Input Area -->
<p> </p>
<%= sql %>
热门信息
阅读 (109)
1 什么样的编程语言是最值得我们学习的呢?阅读 (109)
2 asp 如何解析api接口返回的xml阅读 (109)
3 ASP-数组阅读 (108)
4 asp网站伪静态化URL Rewrite中的httpd.ini伪静态化规则编写方法阅读 (105)
5 asp取access数据库里本周、本月、本季度的记录~