basically here is the deal:
sql is the langauge you use to ask questions to the database server.
The database server then uses the data that is stored in it to answer those questions for you.
The questions can be complex or simple.
For example:
If I have a pay roll database I may want to ask questions like:
Who makes the least? (select * from employees order by salary limit 0,1)
Who makes at least 10% more then Joe? (select a. from employees as a, employees as b where a.emp_id != b.emp_id AND a.salary >= (b.salary 1.1) AND b.emp_name = 'Joe')
So what you do in php to interact with a database is this.
Step 1) Put your question into clear concise english.
Step 2) Translate that question into sql with the help of the mysql manual
Step 3) Implement the translated question in php by storing it in a variable
Step 4) Use the mysql_* commands in php to execute the query and retrieve the data
Step 5) Write the php to manipulate the data any way you like.
That's really all there is too it.