5
Cmagana, you may try searching the forums, expecially the usage and modules ones. There have been some people that posted ways to do what you want to do. I know how to do the php blocks, you just leave off the at the top and end and then save the block as php. When you save a block as php, you don't need the opening and closing php tags.
As for connecting to the database, I know I saw something about how to do this with a regular php page on the forums. You could take that and use it in a block maybe.