title: How to insert data to a mysql database from an HTML Table
body: <p>I have a <strong>HTML table</strong> with information. Right now I can <strong>add rows</strong> and <strong>delete</strong> the rows with a button using javascript. I can also add the information to the database directly using the <strong>Add Rows</strong> button, and remove the data from the database with the <strong>Delete Rows</strong> button. But I don't want to use those buttons because I think it is better to have another button for inserting all the information to the database at once. So I need suggestions on how to read information from a HTML table and inserts its data to a mysql database.</p>
  
  <p>Here is the code:
  Right now the code does not insert data to the database.</p>
  
  <pre><code>&lt;HTML&gt;
  &lt;HEAD&gt;
  &lt;TITLE&gt; Add/Remove dynamic rows in HTML table &lt;/TITLE&gt;
  &lt;SCRIPT language="javascript"&gt;
      function addRow(tableID) {
  
          var table = document.getElementById(tableID);
  
          var rowCount = table.rows.length;
          var row = table.insertRow(rowCount);
  
          var cell1 = row.insertCell(0);
          var element1 = document.createElement("input");
          element1.type = "checkbox";
          element1.name="chkbox[]";
          cell1.appendChild(element1);
  
          var cell2 = row.insertCell(1);
          cell2.innerHTML = rowCount;
  
          var cell3 = row.insertCell(2);
          cell3.innerHTML = rowCount;
  
          var cell4 = row.insertCell(3);
          cell4.innerHTML = rowCount;
  
          var cell5 = row.insertCell(4);
          cell5.innerHTML = rowCount;
  
          var cell6 = row.insertCell(5);
          cell6.innerHTML = rowCount;
      }
  
      function deleteRow(tableID) {
          try {
          var table = document.getElementById(tableID);
          var rowCount = table.rows.length;
  
          for(var i=1; i&lt;rowCount; i++) {
              var row = table.rows[i];
              var chkbox = row.cells[0].childNodes[0];
              if(null != chkbox &amp;&amp; true == chkbox.checked) {
                  table.deleteRow(i);
                  rowCount--;
                  i--;
              }
          }
          }catch(e) {
              alert(e);
          }
      }
  
  &lt;/SCRIPT&gt;
  &lt;/HEAD&gt;
  &lt;BODY&gt;
  
  &lt;INPUT type="button" value="Add Row" onclick="addRow('dataTable')" /&gt;
  
  &lt;INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" /&gt;
  
  &lt;TABLE id="dataTable" border="1"&gt;
  &lt;tr&gt;
  &lt;th&gt;&lt;INPUT type="checkbox" name="chk[]"/&gt;&lt;/th&gt;
  &lt;th&gt;Make&lt;/th&gt;
  &lt;th&gt;Model&lt;/th&gt;
  &lt;th&gt;Description&lt;/th&gt;
  &lt;th&gt;Start Year&lt;/th&gt;
  &lt;th&gt;End Year&lt;/th&gt;
  &lt;/tr&gt;
  &lt;/TABLE&gt;
  
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>