I'm drawing XX amount of entries from my database and I need to output them into two HTML cells, like so
() apple () pear () orange () berry
Essentially I'd like them to be alphabetical from top to bottom and left to right but I want it split up half way so each side has the same number of entires (there could be an extra, of course).

To make it harder (not necessary), I'd like to have to option to break it into 3 sections if my number of items is greater than a certain number, say: 0-50 will have two columns, 50+ will have 3 columns.

print qq~ <form action="" method="post"> <table width="400" border="1" cellspacing="0" cellpadding="1"> <tr> <td colspan="2"><div align="center">Select search engines you wish + to submit to </div></td> </tr> <tr> ~; # break up data into 2 or three columns here #<td width="195">&nbsp;</td> #<td width="195">&nbsp;</td> my $data = qq(SELECT id, name FROM engine WHERE status="1"); my $sth = $dbh->prepare($data); $sth->prepare() or die $dbh->errstr; my ($id, $name); $sth->bind_columns(\$id, \$name); #i while($sth->fetch) { print qq(<input type="checkbox" name="choice" value="$id" /> - +$name); } print qq~ </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td colspan="2"><input type="submit" name="Submit" value="Page3" / +></td> </tr> </table> ~;

In reply to how to split html printout into two table cells by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.