使用PHP和MYSQL,当输出达到10时,如何在表中创建新列?

I'm using a PHP array that is gathering data from a mysql database. I'm outputting this info in a table, but the table is too long with all the entries from the DB for my liking. Since it outputs about 20 listings, and only 10 would fit nicely in the table without scrolling,

how would I code my PHP to output 10 database rows (the table is in a while loop, already), each in their own listing BUT THEN when it reaches 10, create a new column right next to the first one, and output the next 10?

  1. Do the query.
  2. Count the results. [ie. 30]
  3. Divide by the max number of rows you want to display. [ie. 10]
  4. Write an outer for loop to write the rows. [ie. from 1 to 10]
  5. Write an inner for loop to write the cells. [ie. from 1 to 3]