0

I have some variables in PHP that I pull out from a database. I want that a certain div in the page shows only when that variable pulls out a specific result.

I came across something like that but it doesn't work. Anybody can help me?

<?php  if ($piano = '7'){?>
  <script>
    $("#wellness").show();
  </script>
<?php } else { ?>
  <script>
    $("#wellness").hide();
  </script>
<?php } ?>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • 2
    `if ($piano = '7')` will always be true. `$piano = '7'` is an assignment and the result of `if ($piano = '7')` is the assigned value. It's different from `false`, `null`, `""` (empty string), then it's `true` – Cid Oct 03 '18 at 12:41
  • 1
    you have to compare it using double equals $piano == '7' – charan kumar Oct 03 '18 at 12:42

0 Answers0