Php Update

PHP update data from MYSQL database

PHP update data from MYSQL database

PHP update data from MYSQL database.
Hello guys today I will show you the basic on how to update data from MYSQL using PHP

To continue this tutorial you must have this following skills below if not please read previous tutorials

  • You must know how to run PHP and phpMyadmin
  • Understand the basic of PHP
  • You must know how to create database and tables
  • You must know how to connect PHP to MYSQL database using mysqli
  • You must understand how to use $_POST and $_GET
  • You must know how to write SQL query

Same with my previous tutorial “PHP Insert new data to MYSQL database“.

  • Database name: db_test
  • Table name: tbl_test
  • Table fields: id, name, age, gender

Note: Before we update something on the database we must never forget to add conditions or else you will update everything.

On this tutorial we are going to update the data that ID is equal to number 2

Now we will use HTML Form

Lets try little advance

The next sample is fetch all the data and select the data that you want to update.

  • We need to create 2 files index.php and update.php
  • We will use $_GET and $_POST


We will fetch all the data from database and we will add edit links that contain the ID of the data that we want to update.


We will get the ID from url by using $_GET.