title: SQLite PHP Not Filling HTML Table
body: <p>I am making an inventory using HTML and SQLite, using PHP to connect to the server and extract data. After extracting data, I need to populate an HTML table however this is not working. When I try to do console.log in order to see what's working, it does not show up in Chrome console. :(</p>
  
  <p>Please ask if the database file is needed as it is a local database file in the working folder.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
      font-family: 'Open Sans', sans-serif;
  }
  
  table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
      padding: 15px;
      text-align: center;
  }
  
  table tr:nth-child(even) {
    background-color: #eee;
  }
  table tr:nth-child(odd) {
    background-color: #fff;
  }
  table th {
    color: white;
    background-color: black;
  }
  
  /* Style the tab */
  .tab {
    overflow: hidden;
    border: 1px solid #ccc;
    background-color: #f1f1f1;
  }
  
  /* Style the buttons that are used to open the tab content */
  .tab button {
    background-color: inherit;
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: 0.3s;
  }
  
  /* Change background color of buttons on hover */
  .tab button:hover {
    background-color: #ddd;
  }
  
  /* Create an active/current tablink class */
  .tab button.active {
    background-color: #ccc;
  }
  
  /* Style the tab content */
  .tabcontent {
    display: none;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-top: none;
      animation: fadeEffect 1s;
  }
  
  /* Go from zero to full opacity */
  @keyframes fadeEffect {
    from {opacity: 0;}
    to {opacity: 1;}
  }
  
  /* Style buttons */
  .btn {
    background-color: DodgerBlue; /* Blue background */
    border: none; /* Remove borders */
    color: white; /* White text */
    padding: 12px 16px; /* Some padding */
    font-size: 16px; /* Set a font size */
    cursor: pointer; /* Mouse pointer on hover */
  }
  
  /* Darker background on mouse-over */
  .btn:hover {
    background-color: RoyalBlue;
  }
  
  .btnadd {
    background-color: DodgerBlue; /* Blue background */
    border: none; /* Remove borders */
    color: white; /* White text */
    padding: 12px 16px; /* Some padding */
    font-size: 16px; /* Set a font size */
    cursor: pointer; /* Mouse pointer on hover */
  }
  
  /* Darker background on mouse-over */
  .btnadd:hover {
    background-color: RoyalBlue;
  }
  
  /* The Modal (background) */
  .modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  }
  
  /* Modal Content */
  .modal-content {
    position: relative;
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border: 1px solid #888;
    width: 80%;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
    -webkit-animation-name: animatetop;
    -webkit-animation-duration: 0.4s;
    animation-name: animatetop;
    animation-duration: 0.4s
  }
  
  /* Add Animation */
  @-webkit-keyframes animatetop {
    from {top:-300px; opacity:0} 
    to {top:0; opacity:1}
  }
  
  @keyframes animatetop {
    from {top:-300px; opacity:0}
    to {top:0; opacity:1}
  }
  
  /* The Close Button */
  .close {
    color: white;
    float: right;
    font-size: 28px;
    font-weight: bold;
  }
  
  .close:hover,
  .close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
  }
  
  .modal-header {
    padding: 2px 16px;
    background-color: #5cb85c;
    color: white;
  }
  
  .modal-body {padding: 2px 16px;}</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      
  &lt;head&gt;
      &lt;title&gt;Inventory Server&lt;/title&gt;
      &lt;link rel="stylesheet" a href="InventoryServer.css"/&gt;
      &lt;link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"&gt;
      &lt;link href="https://fonts.googleapis.com/icon?family=Material+Icons"
        rel="stylesheet"&gt;
  &lt;/head&gt;
  
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  
  &lt;body&gt;
      
  
  &lt;h2 style="text-align: center"&gt;Welcome to the inventory!&lt;/h2&gt;
      
  &lt;!-- Trigger/Open The Modal --&gt;
      &lt;button class="btnadd" id="btnadd"&gt;&lt;i class=material-icons&gt;add_circle&lt;/i&gt;&lt;/button&gt;
  
  &lt;div class="tab"&gt;
      &lt;button class="tablinks" onclick="openLocation(event, 'Kitchen')" id="defaultOpen"&gt;Kitchen&lt;/button&gt;
      &lt;button class="tablinks" onclick="openLocation(event, 'Shed')"&gt;Shed&lt;/button&gt;
  &lt;/div&gt;
      
  &lt;div id="Kitchen" class="tabcontent"&gt;
    &lt;h3&gt;Kitchen&lt;/h3&gt;
      &lt;table style="width: 100%"&gt;
      &lt;tr&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Quantity&lt;/th&gt;
      &lt;th&gt;Unit&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
      &lt;/tr&gt;
          &lt;?php
  
  $db = "inventory.db";
  
  $handle = sqlite_open($db) or die("Could not open database");
  
  $query = "SELECT Name,Quantity,Unit,Description FROM kitchen ";
  
  $result = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));
  
  
  while($row = sqlite_fetch_array($result)) {
              ?&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;?php echo $row['Name']?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['Quantity']?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['Unit']?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['Description']?&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  
              &lt;?php
              }
              ?&gt;
  &lt;?php
  sqlite_close($handle);
  ?&gt;
  
          
  &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;div id="Shed" class="tabcontent"&gt;
    &lt;h3&gt;Shed&lt;/h3&gt;
      &lt;table style="width: 100%"&gt;
     &lt;thead&gt;
      &lt;tr&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Quantity&lt;/th&gt;
      &lt;th&gt;Unit&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
       &lt;?php
              $connect = mysql_connect("inventory.db","root", "", "inventory");
              if (!$connect) {
                  die(mysql_error());
              }
              $results = mysql_query("SELECT * FROM shed ");
              while($row = mysql_fetch_array($results)) {
              ?&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;?php echo $row['name']?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['quantity']?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['unit']?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['description']?&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  
              &lt;?php
              }
              ?&gt;
          
              &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  
  
  &lt;!-- The Modal --&gt;
  &lt;div id="btnAddForm" class="modal"&gt;
  
    &lt;!-- Modal content --&gt;
    &lt;div class="modal-content"&gt;
      &lt;div class="modal-header"&gt;
        &lt;span class="close"&gt;&amp;times;&lt;/span&gt;
        &lt;h2 style="text-align: center"&gt;Add New Item To Inventory&lt;/h2&gt;
      &lt;/div&gt;
      &lt;div class="modal-body"&gt;
        &lt;form action="#" method="post" role="form" data-toggle="validator" class="form-container"&gt;
    &lt;div class="form-group margin-top-m"&gt;
      &lt;label for="name" class="control-label"&gt;Name Of Item: &lt;/label&gt;
      &lt;input type="text" id="nameOfItem" name="nameOfItem" class="form-control" data-error="Please enter the item name!" required&gt;
      &lt;div class="help-block with-errors"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;label for="quantity" class="control-label"&gt;Quantity of Item: &lt;/label&gt;
      &lt;input type="text" id="quantityOfItem" name="quantityOfItem" class="form-control required" data-error="Please enter the quantity of the item!" required&gt;
      &lt;div class="help-block with-errors"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="row"&gt;
      &lt;div class="col-md-6 mid-col"&gt;
     &lt;div class="form-group"&gt;
       &lt;label for="unitOfItem" class="control-label"&gt;Item Unit: &lt;/label&gt;
       &lt;select name="unitOfItem" id="unitOfItem" class="form-control required" data-error="Please select a unit!" required&gt;
      &lt;option value=""&gt;&lt;/option&gt;
      &lt;option value="piece"&gt;piece(s)&lt;/option&gt;
      &lt;option value="grams"&gt;g&lt;/option&gt;
      &lt;option value="kg"&gt;kg&lt;/option&gt;
      &lt;option value="mL"&gt;mL&lt;/option&gt;
      &lt;option value="L"&gt;L&lt;/option&gt;
      &lt;option value="item"&gt;item(s)&lt;/option&gt;
       &lt;/select&gt;
       &lt;div class="help-block with-errors"&gt;&lt;/div&gt;
     &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="col-md-6 mid-col"&gt;
     &lt;div class="form-group"&gt;
       &lt;label for="place" class="control-label"&gt;Select a place: &lt;/label&gt;
       &lt;select name="place" id="place" class="form-control required" data-error="Please select the item location!" required&gt;
                  &lt;option value=""&gt;&lt;/option&gt;
      &lt;option value="Kitchen"&gt;Kitchen&lt;/option&gt;
      &lt;option value="Shed"&gt;Shed&lt;/option&gt;
       &lt;/select&gt;
       &lt;div class="help-block with-errors"&gt;&lt;/div&gt;
     &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
          &lt;div class="form-group"&gt;
      &lt;label for="descriptionOfItem" class="control-label"&gt;Item description: &lt;/label&gt;
      &lt;input type="text" id="descriptionOfItem" name="descriptionOfItem" class="form-control required" data-error="Please enter a valid item description!" required&gt;
      &lt;div class="help-block with-errors"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;p class="margin-0"&gt;&lt;button type="submit" class="btn btn-lg orange w-100 margin-top-s"&gt;Submit&lt;/button&gt;&lt;/p&gt;
   &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  
      &lt;script type="text/javascript" src="require.js"&gt;&lt;/script&gt;
      
  &lt;script&gt;
  // Get the modal
  var modal = document.getElementById('btnAddForm');
  
  // Get the button that opens the modal
  var btn = document.getElementById("btnadd");
  
  // Get the &lt;span&gt; element that closes the modal
  var span = document.getElementsByClassName("close")[0];
  
  // When the user clicks the button, open the modal 
  btn.onclick = function() {
    modal.style.display = "block";
  }
  
  // When the user clicks on &lt;span&gt; (x), close the modal
  span.onclick = function() {
    modal.style.display = "none";
  }
  
  // When the user clicks anywhere outside of the modal, close it
  window.onclick = function(event) {
    if (event.target == modal) {
      modal.style.display = "none";
    }
  }
  
  
  
  document.getElementById("defaultOpen").click();
  
  function openLocation(evt, locationName) {
    // Declare all variables
    var i, tabcontent, tablinks;
  
    // Get all elements with class="tabcontent" and hide them
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i &lt; tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
    }
  
    // Get all elements with class="tablinks" and remove the class "active"
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i &lt; tablinks.length; i++) {
      tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
  
    // Show the current tab, and add an "active" class to the button that opened the tab
    document.getElementById(locationName).style.display = "block";
    evt.currentTarget.className += " active";
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>