#!/usr/local/bin/perl -w use strict; use DBI; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = CGI->new(); print $q->header(); ##Start database connections my $database = "database"; my $db_server = "localhost"; my $user = "user"; my $password = "password"; ##Connect to database, insert statement, & disconnect my $dbh = DBI->connect( "DBI:mysql:$database:$db_server", $user, $password); my $market_stmt = "SELECT DISTINCT market FROM table ORDER BY market ASC"; my $market_sth; $market_sth = $dbh->prepare($market_stmt) or die "Couldn't prepare the query: ".$DBI::errstr; $market_sth->execute() or die "Couldn't execute query: ".$DBI::errstr; my @market = $market_sth->fetchrow_array; #This is some old code where I tried to fetch all rows and store in an array, this should be deleted, I didn't know what I was doing! When deleted, nothing prints in the "while" statement below! print < EOF while (my $market = $market_sth->fetchrow_array) { print "" ; } print < EOF