im not sure if this is what you need
but i use this code to enter a new line in a table
so i have 5 entries
then a new line for the next 5 entries
<?php
$numCols = 5; //how many images per row
$x = $i + 1;
if ($x == $num){
Print "</td></tr>";
} elseif (is_int($x / $numCols)){
Print "</td></tr><tr><td>";
}
?>
good luck