- ASP - Database Table Display
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


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 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

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" 
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'>"
do while not rs.eof
' 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 

' 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 %>

<% end if %>
end if 
<% if u_category <> "" then %>

<a href="<%= rs("link") %>"><%= rs("title") %></a>
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 
' 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
<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 is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

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