Question
Nested Repeat Region
Dreamweaver CS3
ASP / VBScript
Hi,
I'm trying to create a nested repeat region to display a list of categories
and, in brackets afterwards, a count of the number of sub-categories
contained in it E.g.
Cats (12)
Dogs (43)
Fish (92)
Etc
I have managed to create my repeat region ok because as soon as I drop a
field in from the recordset, it loops through them all and displays them
correctly. However, when I try and simply write out the total number of
records found, it doesn't display anything.
Recordset 1 is a straighforward select from the table. Recordset 2 adds a
WHERE clause usinga variable based on the 1st recordset. Here is the code
i'm using for the 2 recordsets:
Recordset 1 :
<%
Dim Level1
Dim Level1_cmd
Dim Level1_numRows
Set Level1_cmd = Server.CreateObject ("ADODB.Command")
Level1_cmd.ActiveConnection = MM_SemiDirectory_STRING
Level1_cmd.CommandText = "SELECT * FROM TBL_Level1 ORDER BY [Description]
ASC"
Level1_cmd.Prepared = true
Set Level1 = Level1_cmd.Execute
Level1_numRows = 0
%>
Recordset 2 :
<%
Dim Level2__varLink
Level2__varLink = "1"
If (level1.fields.item("Level1_ID").value <> "") Then
Level2__varLink = level1.fields.item("Level1_ID").value
End If
%>
<%
Dim Level2
Dim Level2_cmd
Dim Level2_numRows
Set Level2_cmd = Server.CreateObject ("ADODB.Command")
Level2_cmd.ActiveConnection = MM_SemiDirectory_STRING
Level2_cmd.CommandText = "SELECT * FROM TBL_Level2 WHERE Level1_ID = ? ORDER
BY Level1_ID ASC"
Level2_cmd.Prepared = true
Level2_cmd.Parameters.Append Level2_cmd.CreateParameter("param1", 5, 1, -1,
Level2__varLink) ' adDouble
Set Level2 = Level2_cmd.Execute
Level2_numRows = 0
%>
Now for the repeated code :
<%
While ((Repeat1__numRows <> 0) AND (NOT Level1.EOF))
%>
<li><a
href="category.asp?level1=<%=(Level1.Fields.Item("Level1_ID").Value)%>"><%=(Level1.Fields.Item("Description").Value)%>
(<%=(Level2_total)%>)
</li></a>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Level1.MoveNext()
Wend
%>
Can anyone tell me what I need to do to this code to make it display the
number of sub-categories?
Thanks!!!
ASP / VBScript
Hi,
I'm trying to create a nested repeat region to display a list of categories
and, in brackets afterwards, a count of the number of sub-categories
contained in it E.g.
Cats (12)
Dogs (43)
Fish (92)
Etc
I have managed to create my repeat region ok because as soon as I drop a
field in from the recordset, it loops through them all and displays them
correctly. However, when I try and simply write out the total number of
records found, it doesn't display anything.
Recordset 1 is a straighforward select from the table. Recordset 2 adds a
WHERE clause usinga variable based on the 1st recordset. Here is the code
i'm using for the 2 recordsets:
Recordset 1 :
<%
Dim Level1
Dim Level1_cmd
Dim Level1_numRows
Set Level1_cmd = Server.CreateObject ("ADODB.Command")
Level1_cmd.ActiveConnection = MM_SemiDirectory_STRING
Level1_cmd.CommandText = "SELECT * FROM TBL_Level1 ORDER BY [Description]
ASC"
Level1_cmd.Prepared = true
Set Level1 = Level1_cmd.Execute
Level1_numRows = 0
%>
Recordset 2 :
<%
Dim Level2__varLink
Level2__varLink = "1"
If (level1.fields.item("Level1_ID").value <> "") Then
Level2__varLink = level1.fields.item("Level1_ID").value
End If
%>
<%
Dim Level2
Dim Level2_cmd
Dim Level2_numRows
Set Level2_cmd = Server.CreateObject ("ADODB.Command")
Level2_cmd.ActiveConnection = MM_SemiDirectory_STRING
Level2_cmd.CommandText = "SELECT * FROM TBL_Level2 WHERE Level1_ID = ? ORDER
BY Level1_ID ASC"
Level2_cmd.Prepared = true
Level2_cmd.Parameters.Append Level2_cmd.CreateParameter("param1", 5, 1, -1,
Level2__varLink) ' adDouble
Set Level2 = Level2_cmd.Execute
Level2_numRows = 0
%>
Now for the repeated code :
<%
While ((Repeat1__numRows <> 0) AND (NOT Level1.EOF))
%>
<li><a
href="category.asp?level1=<%=(Level1.Fields.Item("Level1_ID").Value)%>"><%=(Level1.Fields.Item("Description").Value)%>
(<%=(Level2_total)%>)
</li></a>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Level1.MoveNext()
Wend
%>
Can anyone tell me what I need to do to this code to make it display the
number of sub-categories?
Thanks!!!
