You can connect to your database from a PHP file with the following code:
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()) ;
mysql_select_db("Database_Name") or die(mysql_error()) ;
Obviously you need to change the highlighted items to represent the actual values for your database.
Once you are connected to your database you can read data or write to your database.