$cols = 3; //Columns per row
for ($i=1; $i<$numImg; $i++) {
$rem = $i % $cols;
//Start new row
if (($i == 1) || (($i > $cols) && ($rem == 1))) {
echo '<tr>';
}
echo '<td>YOUR IMAGE STUFF...</td>';
//End row
if (($i == $numImg) || (($i >= $cols) && ($rem == 0))) {
echo '</tr>';
}
}
//Might need to tweak the IF condition clauses a bit, but it should work... 🙂