命名搜索和详细的超链接

搜索数据库来显示可以点击详细显示的数据提供了浏览你的数据一个很好的方式超链接的摘要。下面的例子将搜索我们的文本输入数据库,从我们的数据库输入和显示示例名称包含姓氏(L-NAME),名(FNAME),独特的ID(UNIQUE_ID所有名的计数器,因为它们被添加到数据库)的。用户将可以搜索的第一个或最后一个名称,然后单击任何结果揭示的详细数据(唯一的ID,这是所有我们在这个数据库中的数据)都在同一个活动服务器网页。注:在服务器上的数据库中包含主要由www.ttasp.net的用户创建的数据,其结果一定包含在数据库中的数据可能是有问题的。
<%
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>&nbsp;</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 %>">
&nbsp;
<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>
&nbsp;
<input type="submit" value="Search">
</form>
</td>
</tr>
</table>
简单生活,希望对大家有用!要觉得本文有价值请分享给您的朋友,生活就是人来人往,分享越多!收获越多!作者:天天ASP家园
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值