Are there any specific functions or methods in PHP that can help detect empty result sets from MySQL queries?

When executing MySQL queries in PHP, it is important to check if the result set is empty before attempting to fetch any data from it. This can be done using functions like mysqli_num_rows() to determine the number of rows returned by the query. If the result set has zero rows, it means it is empty.

// Execute the MySQL query
$result = mysqli_query($connection, "SELECT * FROM table");

// Check if the result set is empty
if(mysqli_num_rows($result) == 0) {
    echo "Result set is empty";
} else {
    // Fetch and process the data
    while($row = mysqli_fetch_assoc($result)) {
        // Process each row
    }
}