搜索数据库来显示可以点击详细显示的数据提供了浏览你的数据一个很好的方式超链接的摘要。下面的例子将搜索我们的文本输入数据库,从我们的数据库输入和显示示例名称包含姓氏(L-NAME),名(FNAME),独特的ID(UNIQUE_ID所有名的计数器,因为它们被添加到数据库)的。用户将可以搜索的第一个或最后一个名称,然后单击任何结果揭示的详细数据(唯一的ID,这是所有我们在这个数据库中的数据)都在同一个活动服务器网页。注:在服务器上的数据库中包含主要由www.ttasp.net的用户创建的数据,其结果一定包含在数据库中的数据可能是有问题的。
检查看看用户是否提交了搜索或者点击了超链接功能
决定用户是否提交了搜索或者点击了链接
如果用户点击了从搜索显示详细数据标题的链接
如果用户点击了从搜索显示详细数据的链接
最后检查没有obs
end if
最后检查没有输入
<%
u_search=request.form("u_search")
u_exp=request.form("u_exp")
u_id=request.querystring("u_id")
检查看看用户是否提交了搜索或者点击了超链接功能
if u_search <> "" or u_id <> "" then
accessdb="testinputdb"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")
决定用户是否提交了搜索或者点击了链接
if u_id <> "" then
sql= "select * from testtable where unique_id=" & u_id
else
sql = "select * from testtable where "& u_exp &" like '%%" &u_search &"%%' "
end if
rs.Open sql, cn
%>
<%'if there are no observations found display no record found
if rs.eof then %>
No selections could be found
<% ' if observations are found display them
else %>
<table BORDER="1">
<tr>
<td>Name</td>
<%
如果用户点击了从搜索显示详细数据标题的链接
if u_id <> "" then %>
<td>Unique ID</td>
<% end if %>
</tr>
<%
rs.movefirst
do while not rs.eof
%>
<tr>
<td>
<a href="<%=request.servervariables("script_name") %>?u_id=<%= rs("unique_id") %>">
<%= rs("lname") %>, <%= rs("fname") %></a>
</td>
<%
如果用户点击了从搜索显示详细数据的链接
if u_id <> "" then %>
<td>
<%= rs("unique_id") %>
</td>
<% end if %>
</tr>
<%
rs.MoveNext
loop%>
</table>
<p> </p>
<%
最后检查没有obs
end if
最后检查没有输入
end if %>
<body bgcolor="#FFFFFF">
<table>
<tr><td>
<form action="<%=request.servervariables("script_name") %>" method="post">
<input type="text" name="u_search" value="<%= u_search %>">
<select size="1" name="u_exp">
<option <% ' if user selected to search by last name list is first in the dropdown menu
if u_exp = "lname" then %>selected <%end if%>value="lname">Last Name</option>
<option <% ' if user selected to search by last name list is first in the dropdown menu
if u_exp = "fname" then %>selected <%end if%>value="fname">First Name</option>
</select>
<input type="submit" value="Search">
</form>
</td>
</tr>
</table>
简单生活,希望对大家有用!要觉得本文有价值请分享给您的朋友,生活就是人来人往,分享越多!收获越多!作者:天天ASP家园