Results 1 to 3 of 3

Thread: Dynamic Site Map help >>>>>

  1. #1

    Thread Starter
    Lively Member tiga's Avatar
    Join Date
    Feb 2004
    Location
    In My Glove Box !!
    Posts
    115

    Dynamic Site Map help >>>>>

    I am trying to create a Site map using the data from an Access database that my intranet already utilises, but I have a little problem.

    The following code sorts my data OK but I only want the Document Group Field to appear once at the top of that grouped data. I then want for this to loop again as the Document Group field has multiple values.

    Does this make sense ?

    Code:
    <table width="100%">
    <%
    i = 0
    	On Error Resume Next
    	rs.MoveFirst
    		do while Not rs.eof
    		if (i mod 2) = 1 Then
    %>
    	<tr>
    		    <td colspan="2" width="100%" align="left"><font class="fieldtitle"><%=rs.Fields("DocumentGroup")%></font>&nbsp;</td> 	
    	</tr>	
      <tr>
        <td width="2%" align="right"><img src="../images/navlink_blue.GIF" width="5" height="7">&nbsp;</td> 
        <td width="98%"><font class="description"><a href="<%=rs.Fields("DocumentName")%>" target="_blank"><%=rs.Fields("DocumentDescription")%></a></font></td>
      </tr>
    <%
    Else
    %>
    	<tr bgcolor="#ffffff">
    		    <td colspan="2" width="100%" align="left"><font class="fieldtitle"><%=rs.Fields("DocumentGroup")%></font>&nbsp;</td> 	
    	</tr>
      <tr bgcolor="#ffffff">
        <td width="2%" align="right"><img src="../images/navlink_blue.GIF" width="5" height="7">&nbsp;</td> 
        <td width="98%"><font class="description"><a href="<%=rs.Fields("DocumentName")%>" target="_blank"><%=rs.Fields("DocumentDescription")%></a></font></td>
      </tr>
    <%
    End If
    i = i+1
    rs.MoveNext
    loop
    %>  
    </table>
    Tiga

  2. #2
    Lively Member
    Join Date
    Sep 2002
    Posts
    103

    Re: Dynamic Site Map help >>>>>

    I would create a variable called something like previousGroup

    At the start of each loop test if previousGroup="", (which it will be for the first record) if so then write out a header. If there is a previousGroup then test if it is the same as the current record's DocumentGroup. If not then write out a header (because this record belongs to a different section). At the end of the loop put the current record's Document Group into previousGroup for the next trip round the loop.

  3. #3
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Dynamic Site Map help >>>>>

    Quote Originally Posted by aidan
    I would create a variable called something like previousGroup

    At the start of each loop test if previousGroup="", (which it will be for the first record) if so then write out a header. If there is a previousGroup then test if it is the same as the current record's DocumentGroup. If not then write out a header (because this record belongs to a different section). At the end of the loop put the current record's Document Group into previousGroup for the next trip round the loop.
    Yes, I use the same method. Make sure that you use SQL "Order By" or "Group By" to group the records.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

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



Click Here to Expand Forum to Full Width