Learn PHP Basics: Master CRUD Operations to Build Dynamic Applications
About Lesson

 1. Create the database 

To manipulate data, we need a database. In this tutorial, we’ll be using XAMPP as our web server. XAMPP provides an environment for PHP and comes built-in with MySQL database, making it perfect for our needs. After you have installed XAMPP, run the program by clicking on its icon. You should see a screen like the following. If they have not been started already, click the start buttons next to Apache and MySQL respectively. Do not start the other services. To create the database: you’ll be using phpmyadmin, a GUI (Graphical User Interface) that makes the process easier.

  1. Open phpmyadmin ( http://localhost/phpmyadmin/)
  2. Click on the “New” link in the left sidebar to be taken to a form where you can name and create the database.
  3. Enter the name “contact_manager” for the “Database name” then click the “Create” button.

To create the table, we will copy the following section of code, and paste it into a form where we can run it and it will generate the necessary table. To do this, select the SQL tab. Paste your code into the text area then click the “Go” button.

CREATE TABLE contacts ( 
 id int PRIMARY KEY AUTO_INCREMENT, 
 name varchar(255), 
 email varchar(255), 
 phone varchar(255), 
notes varchar(255) 
);

After running this command, you can check the structure tab of the “contacts” table to confirm that it was created successfully.