I only see one <td> set - per row - you need one for each column. It's rather congested looking code - spaces and newlines are free - and should be used to easy readability.
roughly, you'd want to have a format as follows:
<table>
for(your loop pars) {
ECHO <tr>
ECHO "<td> $value1 </td>"
ECHO "<td> $value2 </td>"
ECHO "<td> $value3 </td>"
ECHO "<td> $value4 </td>"
ECHO </tr>
}
</table>
Each iteration through the loop creates a row in the table
.