CodeAve.com CodeAve.com - ASP - Database Table Display
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Name Search & Hyperlinks to Detail
Searching a data base to display hyperlinked summaries that can be clicked on to display detail data provides an excellent way to navigate through your data. The following example will search our test input db of names from our example on Database Input and Display which contains last name (lname), first name (fname) and unique id (unique_id a counter of all names as they are added to the db).  The user will can search the first or last name and click on any of the results to reveal the detail data (the unique id, which is all the data we have in this db) all in the same active server page.  Note:  The db on the server contains data primarily created by users of CodeAve.com, as a consequence some of the data contained in the db may be questionable.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<%
u_search=request.form("u_search")
u_exp=request.form("u_exp")
u_id=request.querystring("u_id")
'Checks to see if the user has submitted a search or 
'clicked a hyperlink
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")
'Determines if the user submitted a search or clicked a link
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 the user clicked a link from a search
' display the detailed data titles 
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 the user clicked a link from a search
' display the detailed data 
if u_id <> "" then %>

<td>
<%= rs("unique_id") %>
</td>
<% end if %>
</tr>
<%
rs.MoveNext
loop%>
</table>
<p>&nbsp;</p>
<% 
' end check for no obs
end if
' end check for no input
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: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3