Print array into 4 column HTML table

From: Adam (A_at_A.com)
Date: 06/25/04


Date: Fri, 25 Jun 2004 16:22:45 -0500

I have an array "@row = $sth->fetchrow_array" that comes from a database
query:

$dbh = DBI->connect("DBI:mysql:$database:$db_server", $user, $password);

$statement = "SELECT city FROM trap WHERE $FORM{state}";

$sth = $dbh->prepare($statement) or die "Couldn't prepare the query:
$sth->errstr";

$rv = $sth->execute or die "Couldn't execute query: $dbh->errstr";

$rc = $sth->finish;
$rc = $dbh->disconnect;

So my @row array should have a list of cities that exist for a specific
state that can be virtually unlimited in length. I want to print these
cities in a HTML table that has four columns, here's the HTML for my row:

<TR>
<TD width="25%">
<DIV align=center><FONT
color=#2f2cff>Wheaton</FONT><BR></DIV></TD>
<TD width="25%">
<DIV align=center><FONT
color=#2f2cff>Chicago</FONT><BR></DIV></TD>
<TD width="25%">
<DIV align=center><FONT
color=#2f2cff>Gurnee</FONT><BR></DIV></TD>
<TD width="25%">
<DIV align=center><FONT
color=#2f2cff>Lisle</FONT><BR></FONT></DIV></TD>
</TR>

Obviously the city names in the HTML above should be automatically generated
from the array and not statically printed.

How can I make a PERL loop that prints my table automatically?

Thanks,
Adam



Relevant Pages

  • Re: IE/Firefox XHTML Strict
    ... The http headers may reveal that the content-type of the css is not type/css. ... Here is the HTML: ... You have a 5 level deep nested divs and every div is styled: so, it become extremely difficult to figure out exactly what you are actually coding for. ...
    (alt.html)
  • Re: Massive HTML coding errors
    ... that a validator wouldn't comment on, ... The DTD at the top of your HTML code is invalid! ... those for your images, and a width of, say, 50% for the div that starts ... You need to be more careful when defining "font-family". ...
    (comp.infosystems.www.authoring.html)
  • Re: node.innerHTML = ... not working in IE
    ... > place the suggest_box div node right next to the textbox so ... So why not set the inner HTML before you insert the node (or use W3C DOM ... > thrown on line 10 in CODE SAMPLE 1): ... P element also has an optional closing tag, which may be implied by the ...
    (comp.lang.javascript)
  • Re: node.innerHTML = ... not working in IE
    ... > any indication of how the javascript is interacting with the HTML. ... >> place the suggest_box div node right next to the textbox so ... > opening P tag encountered within a P element will imply that P element's ...
    (comp.lang.javascript)
  • Proper use of HTML and CSS
    ... These lines were inspired by the "DIV without line breaks" posted by ... If you think of the innerText property that just about any html element ... could use a very simple css rule instead: ... and then use the className in the comparison routine. ...
    (comp.infosystems.www.authoring.html)