Still going to need a loop to process the multi-dimensional arrays that that would produce.
Basic loop count strategy
// set up loop count, ie. 3 across page
$c = 3;
// set up rolling counter
$i = 0;
// start processing results
while ($row = mysql_fetch_array($result)) {
// test if you need to start a new <tr> : $i == 0
if ($i==0) {
echo '<tr>';
}
// always output the <td>
echo '<td><a href="' . $row['pic'] . '"><img src="' . $row['thumb'] . '" /></a></td>';
// now count it : $i == number of cells on the row
$i++;
// test if you need the </tr> : 3 cells on the row already
if ($i==$c) {
echo '</tr>';
// and reset the counter
$i=0;
}
}
// now deal with less than 3 in last row
if ($i > 0 ) {
echo '</tr>';
}
Not the most elegant way of doing this by far, but hopfully the processing logic is plain to understand.
I have used the var $c so that you can see how this will work with any number of cells across.