Link to home
Start Free TrialLog in
Avatar of lshane
lshane

asked on

Nested Repeat Region - ASP VBScript - Dreamweaver MX

Hello.  I am using Dreamweaver MX with ASP VBScript (not .NET).

I am trying to create a Nested Repeat Region for a couple of tables:  <products> <productchampions>
(The "product champion" is the expert of a particular product).

Their field layouts are:
<products> {prodNumb, prodName, pcID}
<productchampions> {pcID, pcFirstName, pcLastName}

I can create a "repeating region" to pull the "pcLastName" and "prodNumb", but it will list the name on every row of the product numbers.  Example below:

Last Name:  Product Number
Last Name:  Product Number
Last Name:  Product Number
Last Name:  Product Number


I am trying to get it to only display the last name once, and then list all associated product numbers.  When it has reached the end of all its related product numbers, it will move to the next Last Name and display all of those related product numbers.  Example below:

Last Name: Product Number
                 Product Number
                 Product Number
                 Product Number
Last Name: Product Number
                 Product Number
                 Product Number
                 Product Number

Could someone, please, help me accomplish this?  This is for my team at work.

Thank you,
lshane
ASKER CERTIFIED SOLUTION
Avatar of RaheelHannan
RaheelHannan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Personally, I would use a SHAPE command in this instance...  Basically this creates two recordsets out of one sql command.  ADO handles keeping it separate.  This will probably look confusing if you haven't used shape before, but the syntax should be prettymuch spot on based on the table structure you provided.  You'll need to change the Access file name.

<table>
<%
Dim strConn : strConn = "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("./test.mdb")

Dim strSql : strSql = "SHAPE{SELECT pcID, pcLastName FROM productchampions ORDER BY pcLastName} " & _
                              "APPEND({SELECT pcID, prodNumb} AS rs2 " & _
                              "RELATE pcID TO pcID)"
dim rs : Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSql, strConn
Do While Not rs.EOF
     Set rs2 = rs("rs2").Value
%>
<tr>
     <td valign="top"><%= rs("pcLastName") %></td>
     <td>
%>
     Do While Not rs2.EOF
          Response.Write rs2("prodNumb") &"<br />"
          rs2.movenext
     Loop
<%
     </td>
</tr>
<%
     rs.movenext
Loop
rs.close
Set rs2 = Nothing
Set rs = Nothing
%>
</table>
Avatar of lshane
lshane

ASKER

Hi, RaheelHannan.  That worked great.  Thank you so much.  I appreciate it.
Nested Repeat Regions in Dreamweaver MX

Looks like Ash's solution worked well for Ishane.

I simply wonder if a similar solution is available in PHP as well?

cgustaf