Dryn Dryn - 1 year ago 68
HTML Question

How to hide an html element with php if a button is pressed?

I would like to hide a simple div, if someone click a button. The 'details' var holds an id from db.

<div class="greetings" <?php if(isset($_GET['details'])) {echo " style='display: none'"; } ?>
<p> some text </p>

But id doesn't work. I appreciate any suggestions :)

Answer Source

An alternative way.

$style = "";
    $style = "style='display:none;'";

<div class="greetings" <?php echo $style;?>>
  <p> some text </p>                       ^ You forgot to close