#!/usr/bin/perl use DBI; use CGI qw/:standard/; use strict; my $cgi = new CGI; print header('text/html'); my $color_sent = $cgi->param('colorselect'); my $id_select = $cgi->param('id_select'); if (!$color_sent && !$id_select) { exit; } $color_sent = substr($color_sent, 1); $id_select = substr($id_select, 1); my $dbh = DBI->connect("DBI:mysql:xxxxxxxxxxx:xxxxxxxxxxxx", "xxxxxxxxxxxxx","xxxxxxxxxxxxxxxxxx"); if ($id_select ne 'esult') { #Update the database. } my $get_all_colors = $dbh->prepare(" SELECT color_code, element_id FROM current_information ORDER BY element_id "); $get_all_colors->execute(); #thezip told me about this #if (exists($hash{$value}) { # ... do something ... } #jporter told me about this #$hash{$key} ||= { }; $hash{$key}{$slot} = 'foo'; my $colorchart{0} ||= { }; my $key = 0; while (my ($color_code, $element_id) = $get_all_colors->fetchrow_array) { if (exists($hash{{$element_id}) { # ... do something ... } $colorchart{$element_id} = '$color_code'; $key++; } print qq^ ^; $counter = 0; while ($key >= $counter) { print qq^
^; $counter++; } #this is what I use to have before I wanted to get smart. #while (my ($color_code, $element_id) = $get_all_colors->fetchrow_array) #{ #print qq^
#^; #} $dbh->disconnect(); exit;