Question: I have made a website (php) and it connects to a database so it can have users and post material. Imagine it like a forum. Now how would I go about making an iPhone app that connects to the same database. I am already teaching myself c++ to make the app, but am not sure how I will connect it to the database.

Answer: 
To do web-based databases, the best practice\*\*\* is to use HTTP requests to a PHP script. That way you will not have to establish a database connection from the app, leaving Usernames and Passwords excluded from the actual project. Create some PHP scripts that will do what you need by sending POST and GET variables.

\*\*\*In my experience and preference
You need to build out API end points for all the actions that are possible. 

E.g posts/view posts/edit posts/add

A popular and well documented architecture to use would be REST 
<http://en.wikipedia.org/wiki/Representational_state_transfer>

If you are using a PHP framework there are often helper libraries for creating the API

This tutorial should help you understand it
<http://net.tutsplus.com/tutorials/php/creating-an-api-centric-web-application/>