Dufonzo has asked for the wisdom of the Perl Monks concerning the following question:
This is the first time I've built something like this. This is the work script I wrote, to figure out how to do it. The real script is part of a much larger application.
What I'd like to know is, is there a more elgant way to do this? I don't think this is that bad, but I know there's always a way to use less code. I was also wondering if there is a standard way that a more experienced person would do this.
You can ignore the href's, they're part of the use of this table, long story.
#/usr/bin/perl print "Content-type:text/html\n\n"; print "<html><head><title>Build Table.pl</title></head>\n"; print "<body>\n"; $total_cells = 517; # would be recordset $display_cells = $total_cells / 15; $row_count = 10; # rows for my table $col_count = $display_cells / $row_count; # cols I'll have print "<table cellpadding=\"4\" border=1>\n"; # counters $row_inc = 1; $col_lable = 1; $nav_count = 15; $nav_inc = 15; for($r = 1; $r <= $row_count; $r++) # build rows { print "<tr>\n"; for($c = 0; $c < $col_count; $c++) # build cols { if($nav_count < $total_cells) { print "<td><a href=\"mypage.html?nav=$nav_count\">$col_lab +le</a></td>"; } else { print "<td> </td>"; } $col_lable+=10; $nav_count+=150; } print "</tr>\n"; $row_inc++; $col_lable = $row_inc; $nav_inc+=15; $nav_count = $nav_inc; } print "</table>"; print "</body></html>\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Dynamic Table
by jeffa (Bishop) on Feb 01, 2003 at 23:12 UTC | |
by Dufonzo (Initiate) on Feb 01, 2003 at 23:24 UTC | |
|
Re: Dynamic Table
by mojotoad (Monsignor) on Feb 02, 2003 at 00:44 UTC |