How can PHP be used to update a SQL database record with input values?

To update a SQL database record with input values using PHP, you can use SQL UPDATE query along with PHP variables to set the new values for the record. First, establish a database connection using PHP, then retrieve the input values from a form or any other source. Finally, construct and execute an SQL UPDATE query to update the record with the new input values.

<?php
// Establish a database connection
$conn = new mysqli("localhost", "username", "password", "database");

// Retrieve input values
$id = $_POST['id'];
$newValue = $_POST['new_value'];

// Construct and execute SQL UPDATE query
$sql = "UPDATE table_name SET column_name = '$newValue' WHERE id = $id";
$result = $conn->query($sql);

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

$conn->close();
?>