in reply to Re: Re: Re: Re: Need help , newbie cgi
in thread Need help , newbie cgi

you still don't know what perl is able to do ;)
i post you code the last time because this is slowly getting VERY weird. you surely are able to make it cleaner.
add this method to the script:
############################################################ sub print_total_by_state { ############################################################ my ($data_ref) = @_; my %cache; my $total = 0; foreach (values %$data_ref) { foreach my $state (keys %$_) { $cache{$state} += $_->{$state}; $total += $_->{$state}; } } print "<tr>\n"; print "\t<td>Total by State</td>\n"; foreach my $state (keys %cache) { print "\t<td>", $cache{$state}, "</td>\n"; } print "\t<td>$total</td>\n"; print "</tr>\n"; }
call the subroutine between the table definitions.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Need help , newbie cgi
by britney (Acolyte) on Oct 07, 2002 at 18:29 UTC
    Hi Kabel, Somehow this code sometime it count right, and sometime it count in a wrong column ? Like:
    A|B|C 1|2|3 = 6 3|1|4 = 8 = = = = 4|3|7 = 14 But it will be A|B|C 1|2|3 = 6 3|1|4 = 8 = = = = 4|7|3 = 14
    Do you know why ?