How can a WHERE clause be used in a MySQL query to filter results based on a specific status value?

To filter results based on a specific status value in a MySQL query, you can use a WHERE clause with the condition that matches the desired status value. This condition can be applied to a column that contains the status information in the database table. By specifying the status value in the WHERE clause, only rows with that specific status will be returned in the query results.

$status = 'active';
$sql = "SELECT * FROM table_name WHERE status = '$status'";
$result = mysqli_query($connection, $sql);

if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        // Process each row with the specified status value
    }
} else {
    echo "No results found with the specified status value.";
}