I’ve a table called mytable in my SQL SERVER database that I want to show into my HTML table with ASP.
here is rendered HTML table when I run SELECT * FROM mytable:

from that database I want to group it and change the HTML table into like this:

I want to eliminate the duplicate value and merge the table with rowspan.
how to loop it so it create the rowspan grouped HTML table ?
here is what I made so far:
<%
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open Dsn
response.write "<table border='1' width='100%' cellpadding='5' cellspacing='0'>" &_
"<tr>" &_
"<td align='center' valign='middle' bgcolor='#CCCCCC'><strong>field1</strong></td>" &_
"<td align='center' valign='middle' bgcolor='#CCCCCC'><strong>field2</strong></td>" &_
"<td align='center' valign='middle' bgcolor='#CCCCCC'><strong>field3</strong></td>" &_
"</tr>"
strselect = "select * from mytable"
set qdata = oConnection.execute(strselect)
If qdata.EOF then
Response.write("NO DATA")
Else
Do While Not qdata.EOF
response.write "<tr> " &_
"<td>" & trim(qdata("field1")) & "</td>"&_
"<td>" & trim(qdata("field2")) & "</td>"&_
"<td>" & trim(qdata("field3")) & "</td> " &_
"</tr>"
qdata.MoveNext
Loop
End If
response.write "</table>"
oConnection.Close
Set oConnection = Nothing
%>
This would appear to be a good time to utilize the
GetRows()method of the ADO RecordSet.GetRows()converts the recordset into a multidimensional array which is then fairly trivial to walk through to compare values – an important feature in this case.The following code works with my test data: