If I understand your rationale correctly, you wish to have the columns populated one by one until they reach a point where there is a balance of contant (as closely as possible) across the columns???
Do your query to retrieve the value to populate the table then:
$columns = 4; // Define number of columns our table should have.
$num_results = mysql_num_rows($query);
$col_rows = intval($num_results / $columns);
$count = 1;
?>
<table width="100%">
<tr>
<td width="25%">
<?PHP
while ($details = mysql_fetch_array($query)) {
echo $result['val']; // Echo each value etc as required
$count = $count++; // Increment the count.
if ($count == $col_rows) {
echo "</td>\n";
echo "<td>\n";
$count = 1;
};
};
?>
</td>
</tr>
</table>
<?PHP
There's probably tidier ways of doing it, but this should work.