I'm assuming you have a loop to recover the image source info from the table, then all you need is something based on this (my code is working through a database, but same difference:
<table>
<?
$outcol = 0;
for ($temp = 0; $temp < 9; $temp++) {
$val=($temp+$offset) % 9;
if ($outcol == 0) {
echo "<tr>"."\n";
}
echo "<td>
echo '<img src="'.$siteimages[$val].'.jpg" width=100 height=100 border=0 name="'.$val.'"></a></td>'."";
$outcol = $outcol + 1;
if ($outcol == 3) {
$outcol = 0;
echo "</tr>"."";
}
}
?> </table></td>
the outcol here checks for 3 columns... easy to fix for 5
..
it's used at www.photo-page.net
Hope it helps