SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Indented tree

  1. #1
    SitePoint Addict
    Join Date
    Sep 2003
    Location
    Kingston
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Indented tree

    Sorry to cross-post, but I need some help with this fast, and I figure it may be actually more a database issue than anything else.

    I'm doing a simple doc mgmt system in Access & ASP. The table structure for folders is
    ID.Parent.Name
    and I am trying to generate an indented list of folders/tree view.

    My current (recursive) function is
    Function GetFolderList(Folder)

    SQL = "SELECT ID, Parent,Name "
    SQL = SQL & "FROM Folders "
    SQL = SQL & "WHERE "
    SQL = SQL & "Parent =" & Folder & " "
    SQL = SQL & "ORDER BY Parent,Name ASC,ID"

    Set rs = dataConn.Execute(SQL)

    If NOT rs.EOF Then
    While NOT rs.EOF
    %><%= rs("Name") %><br><%
    Call GetFolderList(rs("ID"))
    rs.MoveNext : WEnd
    End If

    rs.Close
    Set rs = Nothing

    End Function
    This gives me the parent folders and their subfolders, but how can I print them out indented, showing the tree structure?

    Any ideas?

  2. #2
    SitePoint Addict
    Join Date
    Sep 2003
    Location
    Kingston
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I modded the function slightly to provide an indent which is not 100% perfect but it works. If anyone is interested
    <% Function GetFolderList(Folder,Run)


    SQL = "SELECT ID, Name,Parent "
    SQL = SQL & "FROM Documents "
    SQL = SQL & "WHERE "
    SQL = SQL & "Parent =" & Folder & " "
    SQL = SQL & "ORDER BY Parent,Name ASC,ID"

    Set rs = dataConn.Execute(SQL)


    If NOT rs.EOF Then
    While NOT rs.EOF
    If Run > 0 Then
    %><%= Replace(Space(Run) & " " & rs("Name")," ","&nbsp;") %><br><%
    Else
    %><%= rs("Name") %><br><%
    End If
    Call GetFolderList(rs("ID"),rs("Parent") + 1)
    rs.MoveNext : WEnd

    End If

    CleanUp(rs)

    End Function %>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •