I want to automatically connect to the database and pull data from the tables. Can somebody tell me how to do that? I know PHP & MYSQL so I just need to get the files in order to get the query to work...

I'm working from a theme folder if that's important.