Dynamic data/tables printed from the DB. Need to get how many times have the teams WON, TIED, LOST. Super new to jQuery and no clue what to start coding with (?!). I was thinking of first getting the row where Chelsea appears, then comparing scores, using arrays to store W, T, L — and printing the results at the end (?).
This is what the table looks like:
<table>
<tr id="12">
<td class="238 ekipi_1">Chelsea</td>
<td class="231 ekipi_2">ManU</td>
<td class="goals_238">4</td>
<td class="goals_231">2</td>
</tr>
<tr id="13">
<td class="242 ekipi_1">Reading</td>
<td class="238 ekipi_2">Chelsea</td>
<td class="goals_242">3</td>
<td class="goals_238">3</td>
</tr>
<tr id="16">
<td class="251 ekipi_1">Swansea</td>
<td class="238 ekipi_2">Chelsea</td>
<td class="goals_251">5</td>
<td class="goals_238">3</td>
</tr>
</table>
The result would be:
W T L Chelsea | 1 | 1 | 1 | Reading | 0 | 1 | 0 | ManU | 0 | 0 | 1 |
Any tips for a head start would be greatly appreciated.
To Read the initial data and build the Object you can do this..
Check Fiddle
You can read the teams object and print it out once you are done..