搜索数据库来显示可以点击详细显示的数据提供了浏览你的数据一个很好的方式超链接的摘要。下面的例子将搜索我们的文本输入数据库,从我们的数据库输入和显示示例名称包含姓氏(L-NAME),名(FNAME),独特的ID(UNIQUE_ID所有名的计数器,因为它们被添加到数据库)的。用户将可以搜索的第一个或最后一个名称,然后单击任何结果揭示的详细数据(唯一的ID,这是所有我们在这个数据库中的数据)都在同一个活动服务器网页。注:在服务器上的数据库中包含主要由www.ttasp.net的用户创建的数据,其结果一定包含在数据库中的数据可能是有问题的。
检查看看用户是否提交了搜索或者点击了超链接功能
决定用户是否提交了搜索或者点击了链接
如果用户点击了从搜索显示详细数据标题的链接
如果用户点击了从搜索显示详细数据的链接
最后检查没有obs
最后检查没有输入
<span style="font-size:14px;"><%
u_search=request.form("u_search")
u_exp=request.form("u_exp")
u_id=request.querystring("u_id")
</span>
检查看看用户是否提交了搜索或者点击了超链接功能
<span style="font-size:14px;">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")</span>
决定用户是否提交了搜索或者点击了链接
<span style="font-size:14px;">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>
<%</span>
如果用户点击了从搜索显示详细数据标题的链接
<span style="font-size:14px;">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>
<%
</span>
如果用户点击了从搜索显示详细数据的链接
<span style="font-size:14px;"> if u_id <> "" then %>
<td>
<%= rs("unique_id") %>
</td>
<% end if %>
</tr>
<%
rs.MoveNext
loop%>
</table>
<p> </p>
<%</span>
最后检查没有obs
end if
最后检查没有输入
<span style="font-size:14px;">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></span>
人生最精彩的不是实现梦想的瞬间,而是坚持梦想的过程。 胜利不是战胜敌人,而是提高自己。我们只要每天进步百分之一,那就是成功。您如果觉得此分享对你有用,那将是我们天天ASP家园对你成功路上的一点帮助!