To update the data into the database we first need to establish the database connection. If you didn't know how to establish the database connection , you can visit this article ⇨PHP database connection
For updating the existing data into the database we just need to learn the query that how to write the update query with where condition. We have to just pass the connection and update query with where condition into the mysqli_query function.
"UPDATE table_name
SET column1 = value1, column2 = value2, column3 = value3, ...
WHERE condition"
mysqli_query($connection , $query)
Now we are going to update the user's record into the below users table.
<?php
$conn = mysqli_connect('localhost', 'root', '', 'myfirstdatabase');
mysqli_query($conn,"UPDATE users SET first_name='Hussain',password='Ali12345' WHERE id=1 ");
?>
Note ! If you don't write the WHERE condition , then all records will updated.
<?php
$conn = mysqli_connect('localhost', 'root', '', 'myfirstdatabase');
$first_name = 'Hussain';
$password = 'Ali12345';
mysqli_query($conn,"UPDATE users SET first_name='".$first_name."',password='".$password."' WHERE id=1 ");
?>