Well, you can't do it directly. You need to first set up an array properly, and then loop through the array. It's kinda hard to explain, but you can't create a table vertically, it has to be written horizontally.
Here's some example code:
<?php
$table = array(); // Will hold all our row info ;)
$i = $k = 0; // Will be our counters
/**
* Assuming that you've executed the query,
* and stored the result resource in the $result
* variable.
*/
$ret_rows = mysql_num_rows($result); // How many rows did we get?
$columns = round($ret_rows/6); // How many columns will we have?
/**
* If you have 10 rows returned, divided by 6, it will
* give you 1.6. So rounding that would be 2.
*/
while($row = mysql_fetch_array($result))
{
if($k==6) { $i++; $k=0; } // Reset things...
$table[$i][] = $row['some_column'];
$k++; // Increment our counter ;)
}
/**
* Now we've got our info into an array, we
* can work with it to create our table. We
* just need to go through the initial array and
* for $n=0; while $n<longest_column, loop through all the columns and display row $n of them:
*/
for($n=0; $n<count($table[0]); $n++)
{
echo '<tr>';
for($i=0; $i<$columns; $i++)
{
// The @ supresses bad array information... you can choose
// to pad the last column of the array, or just supress the
// error messages.
echo '<td>' . @$table[$i][$n] . '</td>';
}
echo '<tr>';
}
?>
That's basically how I'd do it... maybe not the most efficient way... but it works 😉