How to grouping data from database into HTML table with rowspan?

xxxrusxxx

New Member
I've a table called \[code\]mytable\[/code\] in my SQL SERVER database that I want to show into my HTML table with ASP. here is rendered HTML table when I run \[code\]SELECT * FROM mytable\[/code\]:
0TqXL.png
from that database I want to group it and change the HTML table into like this:
hFlaA.jpg
I want to eliminate the duplicate value and merge the table with \[code\]rowspan\[/code\].how to loop it so it create the \[code\]rowspan\[/code\] grouped HTML table ?here is what I made so far:\[code\]<%Set oConnection = Server.CreateObject("ADODB.Connection")oConnection.Open Dsnresponse.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 = http://stackoverflow.com/questions/12105004/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.CloseSet oConnection = Nothing%>\[/code\]
 
Back
Top