PHP PDO CRUD Using MySQL Bootstrap Tutorial

We are going to learn a basic PHP PDO CRUD Using MySQL Bootstrap Tutorial. At the end of this article, we will be able to make a CRUD module in PDO with Bootstrap. So, for the very first, here are some explanation for tools and terminologies that will be use.

  1. PDO = PHP Data Objects. This is a PHP extension that defines a consistent and lightweight interface for accessing databases.
  1. CRUD = Create/Read/Update/Delete. It means, any basic application that has ability to for creating, deleting, updating and reading the records from specific database, we will call it CRUD grid. We know that data is stored in database like MySQL. This interface is not understand able for common web users. So, PHP (server side language) manipulates the database tables to facilitate the front end users to operate their data with a much ease. CRUD grid is a most common operation among web developers. Every senior and good web developer has an idea about it.
  1. Bootstrap: It is very popular HTML, CSS, and JavaScript framework.

We will go step by step to complete our CRUD tutorial. We are creating a CRUD for student management. Here are the table of contents.

Table of contents for PHP PDO CRUD

  1. Creating a database having a table
  2. Establishing the database connection
  3. Creating a Grid for records with add, edit and delete buttons
  4. Creating a create/add page
  5. Creating a read/update page
  6. Creating a page for all form actions

1.Creating a database having a table

We will create a database with name phpclicks in MySQL with the following table. This is a dummy data but you can use your data after the tutorial for your personal use.

2.Establishing the database connection

First you should have the following file structure for PDO crud tutorial, so that we may not face any problem during the tutorial.

Now, open config.php in includes folder and create a database connection.

3.Creating a Grid for records with add, edit and delete buttons

Now, we will create page index.php having a HTML table to read the records from the database. It is a grid layout for our PHP PDO CRUD task. Here, you can see ,in the screenshot, the output.

PHP PDO CRUD tutorial file structure

4.Creating a add page

Now, we will create a page addStudent.php for adding the new records. Here is the the code

5.Creating a read/update page

This time ,we will create a page editStudent.php for reading the values from the database and it will also update the records in the database.

6.Creating a page for all form actions

So for, all the pages are created for our PHP PDO CRUD. Oh! one is remaining. what is that page? The page we are missing is the action page which will  add/update or delete the records. So, create a page process.php in the includes folder. For code reference , please download the demo file or simply place below code. For easy access , I created header.php and footer.php files and these files are included in all the files; index.php, addStudent.php,editStudent.php etc


Download Full Source Code


People are interested in these Articles

How to use PDO database connection in PHP

PDO Wrapper Class in PHP

Ajax Login form using PHP MySQL and PDO
Codeigniter Interesting Articles