##
if( defined $total{$id} ){
$total{$id} += $amt;
}else{
$total{tocredit} += $amt;
}
####
my $sth = $dbh->prepare('select * from accounts where id = ?');
$sth->execute($current_account_id);
my $hr = $sth->fetchrow_hashref;
# a naive way
my %totals = %{$hr};