title: Select row table using ajax and php
body: <p>I have a drop menu that includes some category every category has their own subcategory i want to show them buy selecting category name
  but it's not working, did i miss something or am i doing it completely wrong?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function() {
          $("#error").hide();
          $("#category").change(function(){
              $("#error").hide();
              var category = $("#category").val();
              if (category == "") {
                 $("#error").show();
                  return false;
              }   
              var data = $("#form").serialize();
              $.ajax({
                 type:"POST",
                 url:"index.php",
                 data:data,
                 success: function(){ 
                 }
              });
              return false;
          }); 
      });  
  &lt;/script&gt;
  
  
  &lt;form id="form" name="form"&gt;
      &lt;label for="category" id="error"&gt;Empty&lt;/label&gt;
      &lt;select name="category" id="category"&gt;
          &lt;option&gt;&lt;/option&gt;
          &lt;option value="News"&gt;News&lt;/option&gt;
          &lt;option value="Items"&gt;Items&lt;/option&gt;
          &lt;option value="Updates"&gt;Updates&lt;/option&gt;
      &lt;/select&gt;
  &lt;/form&gt;
  
  &lt;?php
  
  include("connect.php");
  if(!empty($_POST['category'])){
      $sql=$con-&gt;prepare("SELECT * FROM categorys WHERE category=:category ");
      $sql-&gt;bindparam(":category",$_POST['category']);
      $sql-&gt;execute();
  
      while($r=$sql-&gt;fetch()){
          echo $r['subcategory'];
      }
  }
  ?&gt;
  </code></pre>