Donzo has asked for the wisdom of the Perl Monks concerning the following question:
I want to output the contents of a DB table into an HTML table.
The DB table has 600 rows.
I'de like to have the output be formatted as an HTML table with 3 columns of
200 rows each.
<tr> <td>$indexs0-200</td> <td>$indexs201-400</td> <td>$indexs401-600</td> </tr>
I've gotten as far as outputting one long column, but this is
as far as I got.
I'm thinking I need to do a while loop with a for statement in it but I'm not
really sure how to do it.
Heres my code so far: Thanks - Donzo
#!/usr/bin/perl -w use DBI; use strict; use CGI; my $q; $q = new CGI; print $q->header, $q->start_html("District List"); my $dbh = DBI->connect("DBI:ODBC:PM_Pages","","") or die "Cannot conne +ct: " . $DBI::errstr; my $sql = "select District,DIST from Districts"; my $sth = $dbh->prepare($sql) or die "Cannot prepare: " . $dbh->errstr +(); $sth->execute() or die "Cannot execute: " . $sth->errstr(); my $district; my $ID; while (($district,$ID) = $sth->fetchrow_array) { print ("a href=\"$ID\">$district</a> <br> "); } $sth->finish(); $dbh->disconnect; print $q->end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: DBI output in 3 columns
by tilly (Archbishop) on Jul 15, 2001 at 06:17 UTC | |
|
Re: DBI output in 3 columns
by dvergin (Monsignor) on Jul 15, 2001 at 02:42 UTC | |
|
Re: DBI output in 3 columns
by mdillon (Priest) on Jul 15, 2001 at 03:34 UTC | |
|
Re: DBI output in 3 columns
by synapse0 (Pilgrim) on Jul 15, 2001 at 02:24 UTC | |
|
Re: DBI output in 3 columns
by Masem (Monsignor) on Jul 15, 2001 at 02:25 UTC | |
|
Re: DBI output in 3 columns
by jlongino (Parson) on Jul 15, 2001 at 04:01 UTC |