.ASP Nested Repeat Region Question

Discussion in 'Scripts' started by ronnydavis, Jun 21, 2012.

  1. #1
    Hi everyone,

    I have a question on whether or not something can be done, regarding a record I would like to have repeat within a recordset.
    Here is a link to the page I will be talking about: 67.199.102.198/findit/

    On this page, there is a list of MAIN categories, then SUB categories and then BUSINESSES in each resulting SUB category.
    So, this list is generated based on active MAIN and SUB Categories, and then, based on the recordset I have created, I can get it to pull the First BUSINESS record, which is show in Light Blue (ie. Arts & Entertainment (MAIN) - Museums (SUB) - The Galt (BUSINESS)

    What I am trying to do is have all of the active BUSINESS records to repeat in this loop.

    HERE IS THE CODE for the recordset: (after this is the code on the page)

    --- THIS IS THE CODE FOR THE MAIN CATEGORY ---
    [COLOR=#444444][FONT=Verdana]<%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Dim RS_Cat[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Dim RS_Cat_cmd[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Dim RS_Cat_numRows[/FONT][/COLOR]
    
    [COLOR=#444444][FONT=Verdana]Set RS_Cat_cmd = Server.CreateObject ("ADODB.Command"; )[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Cat_cmd.ActiveConnection = MM_ll_main_STRING[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Cat_cmd.CommandText = "SELECT * FROM tblBusCat ORDER BY BusCatName ASC" [/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Cat_cmd.Prepared = true[/FONT][/COLOR]
    
    [COLOR=#444444][FONT=Verdana]Set RS_Cat = RS_Cat_cmd.Execute[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Cat_numRows = 0[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    
    [COLOR=#444444][FONT=Verdana]--- THIS IS THE CODE FOR THE AREA ON THE PAGE THAT THIS ALL HAPPENS, which includes the Recordset for the SUBCAT ---[/FONT][/COLOR]
    
    [COLOR=#444444][FONT=Verdana]<% While ((Repeat4__numRows <> 0) AND (NOT RS_Cat.EOF))%><%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Dim RS_Sub2__MMColParam[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2__MMColParam = "1"[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]If ((RS_Cat.Fields.Item("BusCatID"[/FONT][/COLOR][COLOR=#444444][FONT=Verdana].Value) <> ""[/FONT][/COLOR][COLOR=#444444][FONT=Verdana] Then [/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2__MMColParam = (RS_Cat.Fields.Item("BusCatID"[/FONT][/COLOR][COLOR=#444444][FONT=Verdana].Value)[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]End If[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Dim RS_Sub2[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Dim RS_Sub2_numRows[/FONT][/COLOR]
    
    [COLOR=#444444][FONT=Verdana]Set RS_Sub2 = Server.CreateObject("ADODB.Recordset"; )[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.ActiveConnection = MM_ll_main_STRING[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.Source = "SELECT * FROM tblBusSubCat AS Sub, tblBusinessPages AS Bus WHERE Sub.busCatID = " + Replace(RS_Sub2__MMColParam, "'", "''"[/FONT][/COLOR][COLOR=#444444][FONT=Verdana] + " AND Sub.busSubCatID = Bus.busSubCatID AND Bus.bPageActive = True ORDER BY Sub.busSubCatName ASC"[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.CursorType = 1[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.CursorLocation = 2[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.LockType = 1[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.Open()[/FONT][/COLOR]
    
    [COLOR=#444444][FONT=Verdana]RS_Sub2_numRows = 0[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<% If Not RS_Sub2.EOF Or Not RS_Sub2.BOF Then %>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.MoveLast[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]VarLastRecord = RS_Sub2.Fields.Item("busSubCatID"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Sub2.MoveFirst[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%> <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2"><img src="images/spacer.gif" alt="" width="10" height="10" /></td></tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<tr><td width="2%"><img src="images/spacer.gif" alt="" width="10" height="10" /></td><td width="98%" align="left"><table width="97%" border="0" cellspacing="0" cellpadding="0">[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td width="47" rowspan="2" valign="top" class="Blue11"><table width="100%" border="0" cellpadding="0" cellspacing="0">[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td><a href="business/bus_cat.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "BusCatID=" & RS_Cat.Fields.Item("BusCatID"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value %>"><img src="images/<%=(RS_Cat.Fields.Item("BusImage"[/FONT][/COLOR]: )[COLOR=#444444][FONT=Verdana].Value)%>" alt="" border="0" /></a></td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td><img src="images/spacer.gif" alt="" width="10" height="25" /></td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]</tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]</table></td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td colspan="2" align="left" class="Blue11"><strong><a href="business/bus_cat.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "BusCatID=" & RS_Cat.Fields.Item("BusCatID"; )[/FONT][/COLOR] [COLOR=#444444][FONT=Verdana].Value %>" class="Blue14Bold"><%=(RS_Cat.Fields.Item("BusCatName"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value)%></a></strong></td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]</tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td width="533" align="left" class="Blue11"><img src="images/spacer.gif" alt="" width="10" height="5" /><br />[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<!-- [/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]VarSub = "blaBla"[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]-->[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<% While (Not RS_Sub2.EOF) AND (VarSubCount <> 0)%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%If NOT (RS_Sub2.Fields.Item("busSubCatID"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value) = VarSub Then %>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<table width="522" border="0" cellspacing="0" cellpadding="0">[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td width="522">- <a href="business/bus_sub.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "busSubCatID=" & RS_Sub2.Fields.Item("busSubCatID"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value %>" class="GreyArial14"><%=(RS_Sub2.Fields.Item("busSubCatName"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value)%></a><img src="images/spacer.gif" alt="" width="10" height="10" /><span class="Blue10"><a href="business/bus_detail.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "bPageID=" & RS_Sub2.Fields.Item("bPageID"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value %>" class="Blue10"><%=(RS_Sub2.Fields.Item("bPageName"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value)%></a></span></td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]</tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td><img src="images/spacer.gif" alt="" width="10" height="5" /></td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]</tr>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]</table>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%If NOT (RS_Sub2.Fields.Item("busSubCatID"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value) = VarLastRecord Then %>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<% End If %>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<% End If %>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<!-- [/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]VarSub = RS_Sub2.Fields.Item("busSubCatID"[/FONT][/COLOR]; )[COLOR=#444444][FONT=Verdana].Value[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]-->[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<!-- [/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]VarSubCount = VarSubCount-1[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]-->[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<% RS_Sub2.MoveNext[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Wend[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%><%[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<!-- [/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]VarSubCount = 50[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]-->[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<img src="spacer.gif" width="10" height="5" /></td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<td width="21" align="left" valign="top" class="Blue11"> </td>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]</tr></table></td></tr></table><img src="images/bottom.gif" width="625" height="14" /><% End If ' end Not RS_Sub2.EOF Or NOT RS_Sub2.BOF %>[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]<% Repeat4__index=Repeat4__index+1[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Repeat4__numRows=Repeat4__numRows-1[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]RS_Cat.MoveNext()[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]Wend[/FONT][/COLOR]
    [COLOR=#444444][FONT=Verdana]%>[/FONT][/COLOR]
    Code (markup):


    SO.......... What i'm trying to do is just repeat ALL of the active BUSINESSES, which are "bPageName".

    Can this be done? If so, what do I have to do?

    Thanks in advance<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> Happy Holidays!

    Dan.

    Source :
     
    ronnydavis, Jun 21, 2012 IP