|
-
Jan 17th, 2005, 08:48 PM
#1
Thread Starter
Lively Member
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> </td>
</tr>
<tr>
<td width="2%" align="right"><img src="../images/navlink_blue.GIF" width="5" height="7"> </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> </td>
</tr>
<tr bgcolor="#ffffff">
<td width="2%" align="right"><img src="../images/navlink_blue.GIF" width="5" height="7"> </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>
-
Jan 18th, 2005, 09:20 AM
#2
Lively Member
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.
-
Jan 18th, 2005, 10:20 AM
#3
Re: Dynamic Site Map help >>>>>
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|