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.middlecatego ry "&_
"FROM tbtopcategory TC,tbmiddlecate gory MC,tbconnectcat egory CC "&_
"WHERE TC.topcategoryI D = CC.topcategoryl ink "&_
"AND MC.tbmiddlecate goryID = CC.middlecatego rylink " &_
"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("topcateg ory") &"<br>")
Response.Write( "-----------------------------<br>")
LastTopCat = TopCat
End If
Response.Write( RS("middlecateg ory"))
' 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
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.middlecatego ry "&_
"FROM tbtopcategory TC,tbmiddlecate gory MC,tbconnectcat egory CC "&_
"WHERE TC.topcategoryI D = CC.topcategoryl ink "&_
"AND MC.tbmiddlecate goryID = CC.middlecatego rylink " &_
"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("topcateg ory") &"<br>")
Response.Write( "-----------------------------<br>")
LastTopCat = TopCat
End If
Response.Write( RS("middlecateg ory"))
' 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
Comment