$sth->execute() or die "Cannot execute: " . $sth->errstr(); my %hash; while ( my( $district, $ID ) = $sth->fetchrow_array ) { $hash{ $district } = $ID; } # A number of ways to do it here, this is the best if you # don't know you have an exact multiple of 3.... my @keys = sort keys %hash; # sort by district my $column=0; print "
| ", $dis, " | "; if ( $column == 2 ) { print "