Given a table like this:
Col 1 | Col 2
1 2
1 3
2 4
...and could be any number of 1's, 2's, etc. in Col 1. I want to dynamically output something that would look like this:
<table>
<tr>
<td rowspan="2">
1
</td>
<td>
2
</td>
</tr>
<tr>
<td>
3
</td>
</tr>
<tr>
<td rowspan="1">
2
</td>
<td>
4
</td>
</tr>
</table>
My issue is that, for the above html, I would have to count the number of distinct 1's to find the appropriate rowspan number, then go back and iterate through them for the html output. I was just wondering if there was an easier/quicker way to do something similar where I could just iterate through the records and add something once the next row in Col 1 is different than the last row's Col 1.
I read something that sounded like I could just use rowspan="0" for the first record, and divide the groups up by tbody tags like so:
<table>
<tbody>
<tr>
<td rowspan="0">
1
</td>
<td>
2
</td>
</tr>
<tr>
<td>
3
</td>
</tr>
</tbody>
<tbody>
<tr>
<td rowspan="0">
2
</td>
<td>
4
</td>
</tr>
</tbody>
</table>
...and the rowspan="0" would just span the tbody section it is contained in. I haven't been able to find much info on this method, and I couldn't get it to work in IE or Firefox. So is there anything along those lines that would speed up my html rendering? Thanks in advance.