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

Hi Kabel, Wow I start loving perl, I thought we can not do this in perl. Only application can do this not programing. I just wonder, now i can see Made with State, but if I click on each state count, I will see total for each city ? Example: Toyota|California|San Francisco What do you think ?

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Need help , newbie cgi
by kabel (Chaplain) on Sep 23, 2002 at 18:51 UTC
    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.

      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 ?