how to update data in the database using php and mysqli

Hey guys, Today we are learning PHP WITH MYQLI UPDATE QUERY execute in the database. Then lets start (How to update in data in a database using PHP with MySQL).

Originally published at - 14 Mar 2019 06:20 pm

1. HTML Source Code(Index.php)


$conn=mysqli_connect("localhost", "root", "", "testproject");

$fetchQry=mysqli_query($conn, "SELECT * FROM userdetails WHERE id=1");



<form action="send.php" method="post">

<input type="hidden" name="id" value="<?php echo $rows['id']; ?>">

<input type="text" name="name" value="<?php echo $rows['name']; ?>">

<input type="submit" name="submit" value="Submit">


2. PHP Source Code(send.php)


$conn=mysqli_connect("localhost", "root", "", "testproject");



$query=mysqli_query($conn, "UPDATE userdetails SET name='$name' WHERE id='$id'");


echo"Successfully Inserted";



echo"Inserted Failed";