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

Hi Kabel, I works great, but I still stuck one more thing. How can I sort it by State when it display ? Do you think we can do it ? Thanks

Replies are listed 'Best First'.
Re: Re: Re: Need help , newbie cgi
by fglock (Vicar) on Sep 19, 2002 at 20:49 UTC

    replace

    foreach my $state (keys %$states_ref) { by foreach my $state (sort keys %$states_ref) {
      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|Camry|California|San Francisco What do you think ?
      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 ?
        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.