this should be relativily simple, all you gotta do is set up a for loop to perform the task , and a switch to tell you where in the table are you. for example you run a query saying you want it to get the url of the images in your db.
$query=mysql_query("select imageurl from images");
$queryamount=mysql_num_rows($query);
echo "
<table width='100%' border=0>
";
for ($i=0; $i<$howmany; $i++){
if (!isset($what)) $what='one';
switch($what){
case "one";
$do="<tr><td>";
$what='two';
break;
case "two":
$do="</td><td>";
$what="three";
break;
case "three":
$do="</td><td>";
$do2="</tr>";
$what="one";
break;
}
$image=mysql_result($query, $i, 'imageurl');
echo $do;
echo "<a href='$imageurl'><img src='$imageurl' border=0></a>";
if (isset($do2)) echo $do2;
}
echo "</table>";
I dont know if this code will work, but this should give you an idea