There's no simple answer to your question. First you need a DBMS (presumably mysql). If you have that installed you need a database (the tables). Then you need some queries written in SQL get get data into and out of the table (it appears SQL will be your second programming language). Then you will be ready to put it all together to run the queries from php.
A good place to start would be to work through some of the tutorials or articles on this site, www.mysql.org, etc. I usually find it easier to start with something that works and modify it to do what I want than trying to do everything from scratch.