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; ?>