PHP Update Data


Like Delete You can update the data depending upon your id.  
After inserting data into database if you want to modify the data you can do this by using update query.consider the below example we want to modify last name in our table where Id is equal to 2.

<?php
include('config.php');
$sql = "UPDATE Your_table_name SET lastname='Qwerty' WHERE id=2";

if ($conn->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn->error;
}


?>

If query run the the record will be deleted otherwise the error will be display.

0 Comments