The important answers on how to use DBI and CGI are above. I'd like to add just a small hint. Separate your code from html using a template-tool like HTML::Template or the Template Toolkit makes it much easier to maintain your script in the future.
Comment on Re: Trying to print HTML table, erroring out.