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


Displaying Output Grouped By Category
SQL will help to organize your db output, but in order to display data subsets by category you will to keep track of when a previous category ends and a new one begins. Utilizing a db created of links for products into we can subset db records between the three categories in the db (Toys, Books and Software). Select * from amazon order by category asc will select all the observations in the db and order then by category in ascending (alphabetic) order. You will now have observations output in blocks by category, but a few things are needed in order to recognize when a new category has started from the previous. if category <> last_category then checks the record set value for the current category against the last_category value which in the first iteration is null and in subsequent iterations contains the record set value just prior to the move next command that moves to the next observation. If the next observation has a different value then the category is outputted and all the observation within that category are 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")
' The output data must be ordered by the element
' that you want to use as your category
sql = "select * from amazon order by category asc"
rs.Open sql, cn

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

<%= category %>
end if

<a href="<%= rs("link") %>">
<%= rs("title") %></a>
' 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




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