here is the code i wrote in resopnse to a previous question asking the same thing...
its commented to heck so you should be able figure it out... if not.. please ask
<?php
/// in this example list()=each() can be replaced with a call to mysql_fetch_[row|assoc|object] and will allow the same code structure
/// set up an array of simple data - theoretically some entries returned from a sql query
$array = array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' );
/// choose how many columns to display data in
$columns = 3;
/// prepare the table
echo "<table border=1>\n";
/// while we are not at the end of our array
while ( list(,$item) = each($array) ) {
/// prepare a new row
echo "\t<tr>\n";
/// display the item we just pulled out from while() in column 1
echo "\t\t<td>$item</td>\n";
/// foreach additional column
for ( $i=1; $i<$columns; $i++ ) {
/// if there are any items left
if ( list(,$item) = each($array) ) {
/// show the item
echo "\t\t<td>$item</td>\n";
/// if are trying to reach beyond the end of the array
} else {
/// place a blank
echo "\t\t<td><br /></td>\n";
}
}
/// end the row
echo "\t<tr>\n";
}
/// end the table
echo "</table>\n";
?>