ACF - 如果字段为空,如何不显示数据

this is my code (it is a bit messy, I'm sorry, I'm still a beginner). I'm using ACF (in WordPress), and what I'm trying to do is display certain data to certain logged-in users (for example: user1 has a table filled with different data compared to user2). If user1 has empty able - the table shouldn't be shown. That's why I'm checking the sub-field 'first'. If it's not empty, show all the following data that comes from the code. What am I doing wrong? Maybe I'm messing up with mixing PHP with HTML, I don't know. I'm faced with ACF and PHP for the first time.

I am grateful for any given help. Thank you in advance.

<?php 
$first = get_sub_field( 'first' );

if( ! empty( $first ) ) : ?>
    <h4>My heading</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>First</th>
                    <th>Second</th>
                </tr>
            </thead>
            <tbody>
                <?php
                if( have_rows( 'web_design_development', "$loggeduser" ) ):
                    while ( have_rows( 'web_design_development', "$loggeduser" ) ) : the_row(); ?>
                        <tr> 
                            <?php
                            $first = get_sub_field('first'); 
                            $second = get_sub_field('second');                                               
                            ?>
                            <td><?php echo $first; ?></td>
                            <td><?php echo $second; ?></td>            
                        </tr>
                    <?php endwhile; ?>
                <?php endif; ?> 
            </tbody>
        </table>
    </div>
<?php endif; ?>

To check if an ACF sub-field is empty, use get_sub_field combined with an if-statement.

You should use the following:

if ( get_sub_field( 'first' ) :
     echo '<td>' . get_sub_field( 'first') . '</td>';
endif;

To check if not-set, use if ( ! get_sub_field( 'first' ) : (notice the !).