php - create columns from mysql list
- by user271619
I have a long list generated from a simple mysql select query.
Currently (shown in the code below) I am simply creating list of table rows with each record. So, nothing complicated.
However, I want to divide it into more than one column, depending on the number of returned results. I've been wrapping my brain around how to count this in the php, and I'm not getting the results I need.
<table>
<?
$query = mysql_query("SELECT * FROM `sometable`");
while($rows = mysql_fetch_array($query)){
?>
<tr>
<td><?php echo $rows['someRecord']; ?></td>
</tr>
<? } ?>
</table>
Obviously there's one column generated. So if the records returned reach 10, then I want to create a new column. In other words, if the returned results are 12, I have 2 columns. If I have 22 results, I'll have 3 columns, and so on.