title: Live search with php mysql ajax
body: <p>I try to create a live search using <code>php mysql ajax</code> </p>
  
  <p><strong>Input field</strong> </p>
  
  <pre><code>&lt;input type="text" onkeyup="getProducts(this.value)" class="form-control"&gt;
  </code></pre>
  
  <p><strong>Display result of search</strong></p>
  
  <pre><code> &lt;div id="results"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>Ajax googleapis connection</strong></p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><strong>Fuction getProducts</strong></p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
          function getProducts(value) {
              $.post("getProducts.php", {
                      partialState: value
                  }, function(data) $("#results").html(data);
              });
  
          }
  
      &lt;/script&gt;
  </code></pre>
  
  <p>getProducts.php code page </p>
  
  <pre><code>include("includes/connect.php");
  
  $partialStates=$_POST['partialState'];
  
  $states=mysqli_query($conn,"
          select 
          p.db_pcode,
          p.db_pname,
          p.db_punit,
          p.db_pprice,
          p.db_pqtyalert,
          p.db_pcategory,
          p.db_psupplier,
          p.db_pdesc,
          p.db_pvat,
          p.db_pdate,
          p.db_corid,
          c.db_ccat as categoryname,
          su.db_sname as suppliername,
          s.db_secname as blockname,
          s1.db_secid as cornerid,
          s1.db_secname as cornername,
          s2.db_secid as sectionid,
          s2.db_secname as sectionname
          from tbl_products as p
          left join tbl_category as c
          on 
          c.db_cid=p.db_pcategory
          left join tbl_suppliers as su
          on
          su.db_sid=p.db_psupplier
          left join tbl_section as s
          on
          s.db_secid=p.db_corid
          join tbl_section as s1
          on 
          s.db_parent=s1.db_secid 
          join tbl_section as s2
          on
          s1.db_parent=s2.db_secid 
          where 
          p.db_pname like '%$partialStates%'
          ")or die(mysqli_error($conn));
  while($state=mysqli_fetch_array($states)){
      echo"&lt;div&gt;".$state['db_pname']."&lt;/div&gt;";
  }
  </code></pre>
  
  <p>The Problem is that the code don't display any thing </p>
  
  <p>i try to open the getProducts.php page to see if i have any php error </p>
  
  <p>but no error appear and the products are print</p>
  
  <p><strong>Can any one help to know where is the mistake ??</strong>
  in the console i have this 2 errors</p>
  
  <p>Uncaught SyntaxError: Unexpected identifier</p>
  
  <p>2products.php:124 Uncaught ReferenceError: getProducts is not defined</p>