Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI.pm tables

Status
Not open for further replies.

sulfericacid

Programmer
Joined
Aug 15, 2001
Messages
244
Location
US
Without the documentation on perldoc or cspan, can someone show me how to make a table using CGI? I'm just looking for an example on how to start/end a table and how to use tr/td's and how to add data to the td's, can someone help me with this?

Thanks.

sulfericacid "Age is nothing more than an inaccurate number bestowed upon each of us at birth as just another means for others to judge and classify us- sulfericacid
 
cspan?

#!/usr/bin/perl
use CGI qw/:standard :html3 start_table font shortcuts/;
use CGI::Carp qw/ fatalsToBrowser warningsToBrowser /;

print header, start_html;

print table(
Tr(
th( 'Column' ),
th( 'Headings ),
),
Tr(
td( 'top left' ),
td( 'top right' ),
),
Tr(
td( 'bottom left' ),
td( 'bottom right' ),
)
);

print start_table, Tr( th( [ @headings ] ) );
foreach my $row_ref ( get_data_rows() ) { # returns array refs
print Tr( td( $row_ref ) );
$tot += $row_ref->[5]; # or something
}
print Tr( td( {-align=>'right',-colspan=>5}, 'Total:' ),
td( $tot ),
),
end_table;
[/code]
"As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top