How to display text if profile fields are not filled?

You could use, what i call flag (don’t remember the profitional term but im sure there is one).

The idea is to create a variable that has a boolean value, depends on the situation, for our example it will be false.

So basicaly from the very start we assume that all fields have no values and every thing is ok, in the foreach we will do the check if the field actualy has a value, if it has, we will set our flag to true.

Now we know that if our flag was false, we can display what we want, but if its true we don’t display.

The code will be like this

$fields = array('Field 1', 'Field 2', 'Field 3', 'Field 4', 'Field 5');

$flag = false;

foreach ( $fields as $field) {

    $data = xprofile_get_field_data($field);
    
    if ($data) {
        echo '<div class="">'. $field .' - '. $data .'</div>';

        $flag = true;
    }
}

if (!$flag) {
    // display here information if all 5 fields are not filled by user
}