Note that atokatim has a missing } in his code (to close the last if() statement) if you use his suggestion.
Another possiblity is the modulo operator:
for($i = 0; $result = mysql_fetch_object($sql); $i++) {
echo $result->some_row . " | ";
if($i % 3 == 0)
echo "<br/>\n";
}
EDIT: Just because I wanted to refresh my knowledge, I tried to make some code that outputted the data in a <table> form... can't seem to condense it down any more than this:
echo "<table>\n";
for($i = 0; $result = mysql_fetch_object($sql); $i++) {
if($i == 0)
echo "<tr>\n";
elseif($i % 3 == 0) // change the 3 to suit # of columns
echo "</tr>\n<tr>\n";
echo '<td>' . $result->some_row . "</td>\n";
}
while($i % 3 != 0) { // the 3 should be the same # as above
echo "<td> </td>\n";
$i++;
}
echo "</tr>\n</table>";