Need some help with a nested loop.
This one (my example code below) prints out a correct 3 column HTML table with the recordset with proper opening and closing HTML tags AS LONG as the GRUOP BY clause is set by the topcategory Db table.
I think I may need a additional loop withing the existing one to handle the one-to-many database query without messing up the HTML table cells and rows.
EXAMPLE CODE:
SQL = "SELECT DISTINCT TC.topcategory,MC.middlecategory "&_
"FROM tbtopcategory TC,tbmiddlecategory MC,tbconnectcategory CC "&_
"WHERE TC.topcategoryID = CC.topcategorylink "&_
"AND MC.tbmiddlecategoryID = CC.middlecategorylink " &_
"GROUP BY TC.topcategory "
RS.Open SQL,Conn
Cols = 3
Response.Write("<table width='570' border='1'>")
If Not RS.EOF then
Do Until RS.EOF
Response.Write("<tr>")
For i = 1 To Cols
If RS.EOF then
Response.Write("<td width='190'>xx")
Else
Response.Write("<td width='190'>")
' I NEED START OF LOOP FROM HERE
TopCat = RS("topcategory")
If LastTopCat <> TopCat Then
Response.Write(""&RS("topcategory") &"<br>")
Response.Write("-----------------------------<br>")
LastTopCat = TopCat
End If
Response.Write(RS("middlecategory"))
' END OF LOOP TO HERE
RS.MoveNext
End If
Response.Write("</td>")
Next
Loop
End If
Response.Write("</tr>")
Response.Write("</table>")
thanks in advance
Torbjorn