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


 


Displaying Output Grouped By Hyperlinked Category
Allowing users to drill through categories is a powerful feature to add to any site or application. The following example will hyperlink all of the distinct categories in our sample db of Amazon.com. When a user clicks on any of the categories all of the titles in the db within that category will be displayed.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<%
u_category=request.querystring("u_category")
accessdb="category" 
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
' Check to see if the user had clicked on a link from the page
if u_category = "" then
sql = "select * from amazon order by category asc" 
else 
sql = "select * from amazon where category='" & u_category &"' order by title asc" 
end if
rs.Open sql, cn
' if there is no match on category then redirct the user to the category page
' this prevents a truncated screen or error message from appearing when users type in the address field
if rs.eof then response.redirect request.servervariables("script_name")
response.write"<body bgcolor='#FFFFFF'>"
rs.movefirst
do while not rs.eof
category=rs("category")
' if the category is not equal to the previous category
' then output the category 
' (On the first interation last_category will be null
' and cause the first category to output)
if category <> last_category then 
%>

<br><b>
<% 
' if the user has not drilled on a category then hyperlink the category 
if u_category = "" then %>

<a href="<%= request.servervariables("script_name") %>?u_category=<%= category %>">
<% end if %>
<%= category %>
<% if u_category = "" then %>

</a>
<% end if %>
</b><br>
<%
end if 
%>
<% if u_category <> "" then %>

<a href="<%= rs("link") %>"><%= rs("title") %></a>
</b> 
<br>
<%
else
end if
' Places the current category value in the last_category field
' After each iteration last_category will be filled with the value 
' of the category from the previous observation 
last_category=category
rs.MoveNext
loop
' Check to see if the user had clicked on a link from the page
if u_category <> "" then 
' if the user has drilled down show a link back to the category page
%>
<br>
<b>
<a href="<%= request.servervariables("script_name") %>">&lt;--Back</a>
<% end if %>

 

 

 



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