HTML View help

HTML View help

Hello all
In my application I am trying to create a HTML view that allows me to capture details for my workers.
The code is attached below:
  1. htmlpage Tankkarte_Details(ID)
    displayname = "Tankkarte Details"
    print = true
    pdf = true
    content
    <%{
        Mitarbeiter  =  Personalien  [ID == input.ID.toLong()];%>                <strong>&nbsp;Mitarbeiter</strong>: &nbsp;<u><%=Mitarbeiter.Name%> &nbsp; &nbsp;&nbsp;<%=Mitarbeiter.Vorname%></u><%if (Mitarbeiter.ID  ==  input.ID.toLong())
        {%>                        <table width="200" border="3" align="center" cellpadding="2" cellspacing="2">
        <caption><span style="color: rgb(0, 0, 255);"><strong>Tankkarte Details</strong></span></caption>
        <tbody>
            <tr>
                <th scope="row">Monat<span class="Apple-tab-span" style="white-space:pre">        </span></th>
                <td><strong>&nbsp; Betrag (CHF)</strong></td>
    </tr>
             <%for each rec in Tankkarte  [recID == Mitarbeiter.ID]
            {%>                        

       <tr>
    <td style="text-align: center;">&nbsp;<%=rec.Monat%>  </td>
    <td style="text-align: center;">&nbsp; <%=rec.Betrag%>  </td>
    </tr>                                    <%}%>                        
        </tbody>
    </table>
    &nbsp;              <%}
    }%>

I would like the output of the HTML to also include a totals row: which would sum up all the entries for a specific worker.

My idea is to have output as follows:
Worker: XYZ
Month Amount
Jan      150
Feb      100
Mar       200
Total    450

The total should be a sum of all the (Amount entries).

Does any one know how to script that code?

Additinally; I would like to create a HTML view which has the following output
Worker  Jan  Feb  Mar  Apr  Mai  Total
XYZ        150  100   200  -      -       450

Could someone help me with this?

Thank you