title: instant search not working
body: <p>The code below was for instant search, such as google search.</p>
  
  <p>Note that I didn't include the connect to database function here. Coz I think the database username and password setting would be different to yours.So please create your own if you want to test it. The mysql is set with a table is called "objects", and it has one column named "name". </p>
  
  <p>whenever I type in anything, another new search box pop up, where I was expecting the search result.</p>
  
  <p>Could anyone help PLEASE! I stuck on this for almost a day and need it working by tomorrow.. Thanks in advance!!</p>
  
  <pre><code>&lt;!-- display the search area --&gt;
  &lt;html&gt;
  &lt;!-- google API reference --&gt;
  &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;!-- my own script for search function --&gt;
  
  &lt;center&gt;
  &lt;form method="POST"&gt;
      &lt;input type="text" name="search" style="width:400px " placeholder="Search box" onkeydown="searchq();"&gt;
      &lt;input type="submit" value="&gt;&gt;"&gt;
      &lt;div id="output"&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;/center&gt;
  &lt;/html&gt;
  
  &lt;?php
  $output="";
  if(isset($_POST["searchVal"])){
      //get the search
      $search=$_POST["searchVal"];
      //sort the search
      $search=preg_replace("#[^0-9a-z]#i","",$search);
      //query the search
      $query=mysqli_query($conn,"SELECT * from objects WHERE name LIKE '%$search%'") or die("could not search!");
      $count=mysqli_num_rows($query);
      //sort the result
      if($count==0){
          $output="there was no search result";
      }
      else{
          while($row=mysqli_fetch_assoc($query)){
  
              $object_name=$row["name"];
  
              $output.="&lt;div&gt;".$object_name."&lt;/div&gt;";
          }
      }
  }
  
  
  ?&gt;
    &lt;!-- instant search function --&gt;
   &lt;script type="text/javascript"&gt;
  function searchq(){
      // get the value
      var searchTxt = $("input[name='search']").val();
      // post the value
      $.post("search.php",{searchVal: searchTxt},function(output){
          $("#output").html(output);
      });
  }
  
  &lt;/script&gt;
  </code></pre>