Seperating a Table by Category.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GazMathias
    Recognized Expert New Member
    • Oct 2008
    • 228

    Seperating a Table by Category.

    Hi all,

    I am writing a page for our intranet that lists useful office documents / dashboards. At the moment I am simply just looping the recordset into a table.

    I would like to add a bit of seperation to the table, using the document's category, of the format:

    Category Name or Pic
    |Table | Table | Table|

    Category Name or Pic
    |Table | Table | Table|

    Etc.

    Gaz
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    It would help if I could see the loop you have set up now that writes out your table.

    Offhand you will need something to be able to check these categories your talking about.

    Are all the documents named a certain way? Are the documents separated by folders that also represent these categories?

    If either of those are true you should be able to do what you want with some checks on those properties.

    Code:
    Select Case fso.FolderName
          Case "MyCategory"
         'place these files into an array to print out this table
          Case "MyCategory2"
         'place these files into an array to print out this table
    End Select
    This is a very quick general example (honestly im not even sure if the FSO syntax is right ;) but it should give you an idea.

    Comment

    • GazMathias
      Recognized Expert New Member
      • Oct 2008
      • 228

      #3
      Hi,

      Thanks for the reply.

      I am not using the filesystem to find the documents, as they are stored in such a wide range of directories, and moving them to one place would be impractical.

      Everything is read from a database that the users manage through the site itself.

      I got there in the end:

      First, I added an ORDER BY Category clause to the sql statment.

      I then used a loop structured like the following:

      Code:
      <%
      Dim cat
      
      cat =""
      
      Do While Not RS.EOF
      
      If Not Cat = RS("Category") Then 
      %>
      
      <Row to output if category header>
      
      <% 
      cat = RS("Category") 
      End IF 
      %>
      
      <rows containing document info>
      
      <%
      RS.Movenext
      Loop
      %>
      Hopefully, that will be of some use to someone else!

      Gaz

      Comment

      Working...