Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd recommend using an unordered list -- <code>&lt;ul&gt;</code>, and apply the CSS <code>float</code> attribute to its list items (<code>&lt;li&gt;</code>). That way, you won't have to worry about counting the number of records.</p> <p>Just output each record in a <code>&lt;li&gt;</code>, and set them all to <code>float: left;</code>.</p> <p>Then constrain the height of the <code>&lt;ul&gt;</code> so it will be short enough to force the extra <code>&lt;li&gt;</code>s to float to a new column.</p> <p>As @Steve pointed out, you'll also need to set the <code>&lt;li&gt;</code> width to be constant so the columns will be consistent. And make the width of your <code>&lt;ul&gt;</code> more than twice and less than three times as big as the <code>&lt;li&gt;</code> width.</p> <p>A basic way to do that would be to call <code>mysql_num_rows()</code> on your query. Multiply the result by the height of each <code>&lt;li&gt;</code>, then divide by two, and that will be the height of your <code>&lt;ul&gt;</code>. That will make each column of equal height.</p> <p>You <em>could</em> also do it with <code>&lt;div&gt;</code>s (one <code>&lt;div&gt;</code> for each item, all wrapped in a single global <code>&lt;div&gt;</code>).</p> <p>But using a list is the preferred way of displaying a list of information in HTML (unless the information is tabular in nature and requires multiple columns per field, which yours isn't and doesn't).</p> <p>If you need more detailed help, there's a <a href="http://dev.opera.com/articles/view/32-styling-lists-and-links/#fauxcolumns" rel="nofollow">great Opera Web Standards article</a> on this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload