view raw
Dryn Dryn - 6 months ago 38
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 :)


An alternative way.

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

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