How can the code be optimized to handle updates more efficiently, considering the current approach of individual update statements for each field?

The code can be optimized by combining all the updates into a single SQL statement using the SET keyword to update multiple fields at once. This will reduce the number of queries sent to the database, improving efficiency.

// Assuming $conn is the database connection and $id is the record ID
$sql = "UPDATE table_name SET field1 = :value1, field2 = :value2, field3 = :value3 WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':value1', $value1);
$stmt->bindParam(':value2', $value2);
$stmt->bindParam(':value3', $value3);
$stmt->bindParam(':id', $id);
$stmt->execute();