How to edit and update data by id into mysql database in php mysql
In this post, you will learn how to edit the data and update data into your database using php. So, guys, we will create a form with (our requierment) input fields and one extra input field for sending the ID so we can update the data with this help of id into our database.
We will be using Bootstrap 5 version to design the user interface.
So, Lets get started:
Step 1: Create a table named student and add few records in it:
CREATETABLE`student` (
`id`int(11) NOTNULL AUTO_INCREMENT,
`stud_name`varchar(191) NOTNULL,
`stud_class`varchar(100) NOTNULL,
`stud_phone`varchar(100) NOTNULL,
PRIMARYKEY (`id`)
);
Step 2: Create a file named index.php and paste the below code as follows:
In this file, we have created a HTML form to update the data with few input box as per our requirement and one submit button to perform the action using post method.