CRUD operation with Image Using PHP and MySQLi

0

- Advertisement -

In this tutorial, we will learn how to create CRDU operation with image using PHP and MySQLi.

Files includes in this tutorials

  • phpcrud.sql: Contain the database table structure.
  • dbconnection.php: Used for database connection.
  • index.php: Used to fetch the record from the database.
  • insert.php: Used to insert the new record.
  • read.php: Used to fetch the record of the particular user.
  • edit.php: Used to edit the record.
  • change-image.php: Used to change the profile pic.

Step 1– Create a database

Open browser type http://localhost/phpmyadmin, create a database named ‘phpcrud’. After creating the database run the SQL script or import the SQL file.

MySQL Table tblusers structure

Step 2– Create a database connection file(dbconnection.php)

Step 3– Create an HTML form for data insertion. (insert.php)

Step 4– Now write PHP Code for data insertion and put this code at the top of the insert.php file.

Step 5– Read / Fetch the record from the database(index.php)

In this step, we will read/fetch all data from the database including images.

Step 6–Read / Fetch the particular record (read.php)

create read.php file. For fetching a record we have to get the row id of that record and store it in $vid. We access the $_GET[‘viewid’] variable to do it.
Code for gets a record based on the given id. 

Step 7 –Edit/ Update the particular record (edit.php)

Step 7.1 Fetch the data in the HTML Form.

create edit.php file. For updating a record we have to get the row id of that record and store in $eid. We access the $_GET[‘editid’] variable to do it.
Code for gets a record based on the given id. In this way, we can get data autofill-data in HTML Form.

Step 7.1 Code for update the particular record. Put this code on the top of the edit.php

Step 7.3 create a page for image updation. (change-image.php)

create change-image.php file. For updating a profile pic we have to get the row id of that record and store it in $eid. We access the $_GET['userid'] variable to do it.

Step 7.4 Code for update the particular user profile pic. Put this code on the top of the change-image.php

Step 8 – Code for data deletion a record from the database

Download Source Code (php-mysqli-crud-with-image)
Size: 201 KB
Version: V 1.0

- Advertisement -

Leave A Reply

Your email address will not be published.