PHP Practical Tutorials | jQuery and Webpage Design Home

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:

mysql database structure

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.

  1. Connect with MySQL server.
  2. Select a MySQL database to work with.
  3. Peform query on MySQL database tables, e.g. read data, update data, insert data or delete data.
  4. Display results on the screen, if required.
  5. 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.