<%
Sub Write_HTML
Dim r, count'r is an index variable for the for loops, count is the number of rows of data
Dim arrTotals(50)
count = rsData.Fields.Count - 1
' r = "0"
for r = 0 to count
arrTotals(r) = "0"
next
rsData.MoveFirst
'recordsets start at zero
'first generate the start of the table
Response.Write("" & vbCrLf)
Response.Write("" & vbCrLf)
for r = 0 to count 'populate the header
Response.Write("| " & rsData(r).Name & " | " & vbCrLf)
Next
Response.Write("" & vbCrLf)
'Now populate the table
Do Until rsData.EOF
Response.Write("" & vbCrLf)
Response.Write("| " & rsData(0) & " | " & vbCrLf)
for r = 1 to count
Response.Write("" & rsData(r) & " | " & vbCrLf)
arrTotals(r) = arrTotals(r) + rsData(r)
Next
Response.Write("
" & vbCrLf)
rsData.MoveNext
Loop
Response.Write("" & vbCrLf)
Response.Write("| Totals | ")
for r = 1 to count
Response.write("" & arrTotals(r) & " | " & vbCrLf )
Next
Response.Write("
" & vbCrLf)
Response.Write("
")
End Sub
%>