A method you can use is the % operator which, if you are using a FOR loop is very handy and extremely easy.
start your table first, and do an itial <tr>, then mod your for counter by the number of columns you want. In the example below i have used 3.
<?php
print "<tr>";
for ($i=0; $i<$limit; $i++)
{
if ($i%3 == 0) print "</tr><tr>";
print "<td>output</td>";
}
print "</tr>";
?>
This will end a row and start another one every three cells.
You can do the same with rows, just change the if statement.
Rich.