Moreno, Javier <> wrote:
> Hi all,
>
> How can I create tables dynamically with CGI? I have the following:
>
> #################
> print $DRepA-> table({-class=>'VersionControl',-width=>'100%'},
>
> $DRepA->Tr({-class=>'Header'},
>
> [
>
> $DRepA->td(["Modification date", "Name", "Description", "Version"])
>
> ]
> ),
>
> $DRepA->Tr(
>
> [
>
> $DRepA->td(["November 9, 2005", "Javier Moreno", "Creation", "0.1"])
>
> ]
> ),
>
> $DRepA->Tr(
>
> [
>
> $DRepA->td(["April 6, 2006", "Javier Moreno", "Complete revamp",
> "1.0"])
>
> ]
> ),
> );
> #################
>
> Basically, how can I do the following:
>
> #################
> print $DRepA-> table({-class=>'VersionControl',-width=>'100%'},
>
> $DRepA->Tr({-class=>'Header'},
>
> [
>
> $DRepA->td(["Modification date", "Name", "Description", "Version"])
>
> ]
> ),
> foreach
> (@{$sql_fetched_array}) {
> $DRepA->Tr(
>
> [
>
> $DRepA->td([EMAIL PROTECTED],@{$_}[1],@{$_}[2]])
>
> ]
>
> ),
> }
> );
> #################
>
> Thanks and regards,
Hmmm... You appear to live near a white space mountain!
Try this:
---------------------------------------------------------
use strict;
use warnings;
use CGI::Pretty qw{:standard};
my @headings = ("Modification date", "Name", "Description", "Version");
my $sql_fetched_array
= [["November 9, 2005", "Javier Moreno", "Creation", "0.1"],
["April 6, 2006", "Javier Moreno", "Complete revamp", "1.0"]
];
print table({-class=>'VersionControl',-width=>'100%'},
Tr({-class=>'Header'},
[
td([EMAIL PROTECTED])
]
),
map {Tr(td($_))} @$sql_fetched_array);
---------------------------------------------------------
See 'perldoc -f map'
HTH
--
Brian Raven
=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the
intended addressee(s). Unauthorised reproduction, disclosure, modification,
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message do not
necessarily reflect those of Atos Euronext Market Solutions.
L'information contenue dans cet e-mail est confidentielle et uniquement
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee.
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail
vous parvient par erreur, nous vous prions de bien vouloir prevenir
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre
systeme. Le contenu de ce message electronique ne represente pas necessairement
la position ou le point de vue d'Atos Euronext Market Solutions.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs