What are some common methods for updating recordsets in PHP when using mySQL?

When working with recordsets in PHP and mySQL, common methods for updating records include using the UPDATE statement in SQL queries and executing them through PHP. This involves setting the new values for the fields in the recordset and specifying the conditions for which records to update.

<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Update record in the database
$sql = "UPDATE table_name SET column1 = 'new_value', column2 = 'new_value' WHERE condition";

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

// Close connection
$conn->close();
?>