the if statement isn't really going to help you much. you need to study up on loops! (pardon me if you already know this). you will need a loop within a loop.
if $number_of_results is a variable with the number of results you have, you want to do something like this (i'm not sure this will work exactly but it just might)
$number_of_cols = 3
echo "<TABLE>\n";
$i = 0
while($i < $number_of_results) {
// this code shouldn't run if there are no results
echo "<TR>\n";
for($col=1, $col <= $number_of_cols, $col++) {
echo "<TD>";
if ($i < $number_of_results) {
echo $result[$i]
}
echo "</TD>";
}
echo "</TR>";
$i++;
}
echo "</TABLE>";
if you need PHP documentation, try PHP.NET
PHP.net documentation page