Creating database and tables with phpMyAdmin

Spread the love

For creating database and tables, we can use phpmyadmin. We can use SQL commands with PHP to create a database table and insert, delete, update table records. We will see this in upcoming lessons.

In this tutorial, I will show you how to create database and table directly using phpmyadmin.

Creating database using below steps:

  1. You can click on “Databases” button present at the top or “New” link present at extream left the side, with a tree view of databases.
  2. After clicking on “creating database” button you will see “Create database” section with one text box and drop down menu. Enter database name say “company_db” in the text box and click on “Create” button.

This will add new database “company_db” in the database list.

Creating table:

Follow below steps to create table inside database “company_db“.

  1. If you want to create database table inside “employees_db” database, you first need to select that database. Click on “company_db” database link. Doing this, the page will get refreshed and you will see at the top of the page, breadcrumb gets updated to : “Server: MySQL wamp server »Database: company_db”. This indicates that you have selected your database.
  2. Now you will see “Create table” section with two text boxes “Name” for the name of the table and “Number of columns” for the count of columns your table will contain. Enter table name “employee” as table name and column count as “4” and click on “Go” button. This will show below page with the fields for table columns.
  3. Create columns by giving them name and datatype. Enter “id” as first column name and “Type” as “INT”. Enter 11 as Lenght/Values. Click on “Index” drop-down and select “PRIMARY” to make this as a primary key column. Select “A_I” checkbox to make it auto increment.
  4. Enter “empname”, “username” and “password” as other columns. Select “VARCHAR” as type and 150 as Lenght for all these columns.
  5. Click on save.

You will see that new table “employees” has been added to the database. Clicking on table name will show the empty result set as there is no record created yet.

In next lesson, we will see how to connect database with PHP and see different operations using PHP on database tables.


Spread the love

Leave a Comment