Show DIV according to PHP condition

Asked

Viewed 2,530 times

2

I have a div that brings a select from the bank, but it can only be shown if it meets a condition. It comes like this:

<div id="conteudo" style="display: none;">

If she meets this condition: if (get('data_do_descredenciamento') != ''), then the display of div must change to style="display: show;".

How can I set this condition in PHP?

  • 1

    Instead of hiding the div it’s no longer simple nor put her on the way out?

1 answer

6


Option 1:

<div style="<?php echo get('data_do_descredenciamento') != '' ? 'show' : 'none'; ?>">
</div>

Option 2:

<div style="<?php if (get('data_do_descredenciamento') == '') { echo 'display: none;' }">
</div>

Option 3:

<?php if (get('data_do_descredenciamento') != '') { ?>
    <div>
    </div>
<?php } ?>
  • 1

    Just suggesting an improvement, the return show is unnecessary, could be exchanged for null why the option show inside the property display there is no.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.