View Single Post
  #2 (permalink)  
Old December 12th, 2003, 06:40 AM
pgtips pgtips is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok, so you've got the category and item in the same recordset. Your SQL is fine, you need to do the grouping in your asp code. You just need to keep track of the category as you loop through the recordset and only output the category when it changes, something like this:
Code:
sCatPrevious = ""
Do While Not rs.EOF

  sCatCurrent = "" & rs.Fields("Category").Value
  If sCatCurrent <> sCatPrevious Then
    ' output the category
    Response.Write sCatCurrent

    ' update the "previous" variable
    sCatPrevious = sCatCurrent

  End If

  ' output the item
  Response.Write "" & rs.Fields("Item").Value

  rs.MoveNext
Loop
Reply With Quote