Data can be updated into MySQL tables by executing SQL UPDATE statement through PHP function mysqli_query.
Below is a simple example to update records into MyGuests table. To update a record in any table it is required to locate that record by using a conditional clause. Below example uses primary key to match a record in MyGuests table.
<?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2 AND name = 'sunil' "; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?>