mercredi 20 décembre 2017

is it possible to have an if function in a foreach loop in php

is it possible to have an if statement in a foreach loop? for me it doesn't work, I have a function like this:

<?php 
        foreach($userdetail_list as $row):

                        ?>
                        <?php if (isset($_SESSION['user_logged']) && $_SESSION['user_logged']=! TRUE){ ?>
                        <a href="<?php echo base_url() ?>/ChatboxController"><input type="button" class="btn btn-primary bs" value="Bericht sturen"></input> </a>
                        <?php endif; ?>
                        <tr>
                            <td><h2><?php echo $row->voornaam;?> <?php echo $row->achternaam;?></h2></td>
                            <td><p><?php echo $row->woonplaats;?></p></td>
                            <h3>Over mij:</h3><td><?php echo $row->beschrijving;?></td><br>
                            <h3>Contactgegevens:</h3>
                             <td><p><?php echo $row->email;?></p></td>


                         </tr>

<?php endforeach;  ?> 

So I'm getting this error:

A PHP Error was encountered
Severity: Parsing Error

Message: syntax error, unexpected 'endif' (T_ENDIF)

Filename: views/profiel_user.php

Line Number: 38

Backtrace:

So it says i didnt end the if statement correctly.

Aucun commentaire:

Enregistrer un commentaire