title: hide div from div when there is no search result
body: <p>I've tried so many methods from stackoverflow and other websites but whenever i succeed in hiding the div. No search result is displayed at all.</p>
  
  <p>I've tried the :empty selector and fiddling around with the php code and js code. but since i'm very new to this i just can't seem to crack the error. What am i doing wrong?</p>
  
  <p><strong>My HTML</strong></p>
  
  <pre><code>            &lt;div class='search'&gt;
              &lt;form class="searchbox" action='index.php' method='post' autocomplete='off'&gt;
                  &lt;input type='text' name='search' class='searchform' placeholder='Søg efter skole...' onkeyup="searchq();"&gt;
              &lt;/form&gt;
              &lt;div id="output"&gt;&lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>    &lt;?php
  
  include("connection.php");
  $output = '';
  //collect
  
  if(isset($_POST['searchVal'])) {
      $searchq = $_POST['searchVal'];
      $searchq = preg_replace("#[^a-zA-Z0-9æøå]#i"," ", $searchq);
  
      $query = mysqli_query($mysqli, "SELECT * FROM `products` WHERE name LIKE '%$searchq%'") or die("could not search");
      $count = mysqli_num_rows($query);
  
       if($_POST['searchVal'] == NULL) {
          $output = '';
      } else {
  
          while($row = mysqli_fetch_array($query)) {            
              $name = $row['name'];
              $id = $row['id'];
              $output .= '&lt;a href="kantine.php?id='.$id.'" class="searchres"&gt;'.$name.'&lt;/a&gt;&lt;br&gt;';
          }  
      }
  }
  
  echo "&lt;div class='output'&gt;$output&lt;/div&gt;";
  
  ?&gt;
  </code></pre>
  
  <p><strong>And JS</strong></p>
  
  <pre><code>                function searchq() {
                  var searchTxt = $("input[name='search']").val();
                  $.post("search.php", {
                      searchVal: searchTxt
                  }, function(output) {
                      $("#output").html(output);
                  });
              }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ZEPtu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZEPtu.png" alt=""></a></p>