in reply to CGI with mysql
You've gotten the right direction by others (to look at DBI), but you might also want to look into Class::DBI which you will love once you get it to work a little.