In PHP, what strategies can be employed to handle missing data from a database query within a loop and display appropriate messages, such as "Unbekannt"?

When querying a database within a loop in PHP, it is important to handle cases where data may be missing. One strategy to handle missing data is to check if the query result is empty and display an appropriate message, such as "Unbekannt", in place of the missing data.

// Sample code snippet to handle missing data in a database query within a loop
$query = "SELECT * FROM table_name";
$result = mysqli_query($connection, $query);

if(mysqli_num_rows($result) > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        $data = $row['column_name'] ?? 'Unbekannt';
        echo $data . "<br>";
    }
} else {
    echo "No data found";
}