PHP MySQL DataBase Basic Concept
We will show how to use PHP interact with MySQL database with a simple example in the next page. Please click here to view PHP and MySQL Interaction Example after reading this tutorial.
Many dynamic websites on the Internet are mainly built up with PHP and MySQL database. Therefore this is a good idea to study how PHP and MySQL database work together.
Basic Concept of MySQL
MySQL is the most popular database on the Internet. Most websites on the Internet are using MySQL because it is powerful and free. The data in MySQL database is stored in tables. And the tables have records and fields. A database can be illustrated with the following schematic diagram:
Note:
- a database can has one or more tables, and
- each table must has a unique name.
How PHP Interact with MySQL Database
This is rather easy to use PHP interact with MySQL database. In order to illustrate the interaction process, it can be broken down in the following five steps.
- Connect with MySQL server.
- Select a MySQL database to work with.
- Peform query on MySQL database tables, e.g. read data, update data, insert data or delete data.
- Display results on the screen, if required.
- Close the connection with MySQL server.
Please note that the interaction with the MySQL database is actually a continous process. This is only for illustration purpose that the whole process is broken down into the above five steps.