<?php
$numcols = 3; // how many data columns we want
$numcolsprinted = 0; // how many columns have been output so far
// create sql and execute
$sql = 'select blah...';
$result = mysql_query ($sql, $conn);
// output the table and first row tag
?>
<TABLE><TR>
<?php
// for each row of data from our database, we are going to output
// a column in our table
while(($row = mysql_fetch_array($result)) {
// If we have already output our required number of columns in
// the current row, close it and open a new row tag.
// Also, reset our row counter to 0 for the new row
if ($numcolsprinted == $numcols) {
print "</TR>\n<TR>\n";
$numcolsprinted = 0;
}
// output data row from database
print "<TD>\n"
// output formatted $row data here.
// Best to put each database row in it's own
// self-contained table
print "</TD>\n";
// increment row counter
$numcolsprinted++;
} // end while
// now we need to print out a balancing number of columns
// for our last row in case there were less than the number
// of columns in the other rows.
$colstobalance = $numcols - $numcolsprinted;
for ($i=1, $i<=$colstobalance, $i++) {
print "<TD> </TD>\n";
}
// print the closing of the last row and close the table
print "</TR></TABLE>\n";
?>
HTH
-- Rich Rijnders
-- Irvine, CA US