You need to use jQ for this.
to count child elements of your tr tag u should use a line like this
$count = $("#myTable tbody tr td").length;
BUT THIS CODE WILL GIVE YOU THE COUNT OF ALL THE TD ELEMENTS IN THE TABLE
i mean if you have 2 tr elements containing 2 td each the selector length above will return 4 instead of 2
You can fix this by giving your tr elements an id then selecting them and counting their childs or td elements inside.
and for appending your footer u could use this.
$("#myTable").append("<tfoot><tr>");
for(i=1,i<$count,i++){
$("#myTable tfoot").append("<th>...</th>")
}
$("#myTable").append("</tr></tfoot>");
Hope this helps!