title: Loading a html table with PHP via a JQuery .load call
body: <p><strong>Aim</strong></p>
  
  <p>I am trying to create a page to delete records from my database.The page would consists of a  that populates itself upon page load.Upon selecting a value from the  and clicking the submit button, a php page would be called and the results of the php would be loaded into a table below the .I can then click on the delete button that would be beside the values echoed to delete that value from the database</p>
  
  <p>My Form:</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;!--Loads JQuery script--&gt;
  &lt;script src="//code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
  &lt;!--Gets list of item categories on page load--&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
      $("#viewsubcat").load("getcategory.php");
  });
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $("#viewsubcatsubmit").click(function(){
      var cat=$('#viewsubcat').val();
      $('#deletetable').load('delsubcategory.php?cat='+cat);
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form style="width:500px" id="viewsubcategory" name="viewsubcategory" method="post" action="&lt;? php echo $_SERVER['PHP_SELF'] ?&gt;" &gt;
      &lt;div class="inputfield"&gt;
          &lt;label for="viewsubcat"&gt;Select Category:&lt;/label&gt;
          &lt;select style="margin-left:37px" id="viewsubcat" name="viewsubcat"&gt;&lt;/select&gt;
      &lt;/div&gt;&lt;br /&gt;
  
      &lt;div class="inputfield"&gt;
          &lt;input style="margin-left:250px" type="button" id="viewsubcatsubmit" name="viewsubcatsubmit" value="Search" /&gt;&lt;/div&gt;
      &lt;/div&gt;&lt;br /&gt;
  &lt;/form&gt;
  
  &lt;table id="deletetable"&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP Page:</p>
  
  <pre><code>&lt;?php
      include("cxn.inc");
      $id=$_SESSION['BizID'];
      $cat=$_GET['cat'];
      $viewsubcat=$cxn-&gt;prepare("SELECT * FROM `itemcat`,`itemsubcat` 
      WHERE `itemcat`.`CatID`=:cat AND `itemsubcat`.`ItemCat`=:cat AND `itemsubcat`.`BusinessID`=:id");
      $viewsubcat-&gt;bindValue(":cat",$cat);
      $viewsubcat-&gt;bindValue(":id",$id);
      $viewsubcat-&gt;execute();
      //echo"&lt;table border='1'&gt;";
      echo"&lt;tr&gt;";
              echo"&lt;td&gt;";
                  echo"Categories";
              echo"&lt;/td&gt;";
              echo"&lt;td&gt;";
                  echo"SubCategories";
              echo"&lt;/td&gt;";
              echo"&lt;td&gt;";
                  echo"Action";
              echo"&lt;/td&gt;";
          echo"&lt;/tr&gt;";
      while($getsubcat=$viewsubcat-&gt;fetch(PDO::FETCH_ASSOC))
      {
          $cat=$getsubcat['ItemCat'];
          $subcat=$getsubcat['ItemSubCat'];
          $subcatid=$getsubcat['SubCatID'];
          echo"&lt;tr&gt;";
              echo"&lt;td&gt;";
                  echo"$cat";
              echo"&lt;/td&gt;";
              echo"&lt;td&gt;";
                  echo"$subcat";
              echo"&lt;/td&gt;";
              echo"&lt;td&gt;";
                  echo"&lt;form id='delsubcategory' name='delsubcategory' method='POST' action='delsubcategory.php'&gt;";
                      echo"&lt;input type='hidden' id='delsubcatid' name='delsubcatid' value='$subcatid' /&gt;";
                      echo"&lt;input type='submit' id='delsubcatsubmit' name='delsubcatsubmit' value='Delete' /&gt;";
                  echo"&lt;/form&gt;";
              echo"&lt;/td&gt;";
          echo"&lt;/tr&gt;";
      }
      //echo"&lt;/table&gt;";
  ?&gt;
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>The HTML Table isn't loading upon pressing the button.The Php page is working when i change the form's action to "delsubcategory.php" and the button type="submit", so the issue lies with the html.</p>
  
  <p>Would appreciate any insights into the matter</p>