#db connect, prepare, exectute goes here.... while($ref = $sth->fetchrow_hashref()) { foreach $opt (@enable_opts) { #@enable_opts is the array of checkbox values #switch statement to perform calculations on values ($ref{'DATE'}) } }