Gibt es eine Möglichkeit, dieses Problem direkt mit SQL zu lösen, anstatt es mit PHP zu implementieren?

The issue is to update a specific column in a database table for multiple rows where a certain condition is met. This can be achieved directly using SQL by writing an UPDATE query with a WHERE clause to specify the condition.

<?php
// Establish database connection
$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 the column 'status' to 'completed' for all rows where 'id' is greater than 5
$sql = "UPDATE table_name SET status = 'completed' WHERE id > 5";

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

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