title: Html dynamic table
body: <p>hey I have a table with just one row ....
  i need to have an add button in my table to add another row ,
  latter when the user clicks on submit all the table data should enter into database .
  I have create a single row table and it works fine for entering the data into database , can any please help me modify my code to have an add row functionality and on submit to enter the data into database . My Html and PHp file are as follows . PLEASE HELP !</p>
  
  <pre><code>&lt;form   name="myForm"
          method="post" 
          action="to_db.php" 
          onSubmit="alert('YOUR REQUEST HAS BEEN RECEIVED.');" &gt;
  
  &lt;TABLE BORDER=0&gt;    
      &lt;TR&gt;
          &lt;TD&gt;Department&lt;/TD&gt;
          &lt;TD&gt;
              &lt;select name="department"&gt;
                  ...
              &lt;/select&gt;
          &lt;/TD&gt;
          &lt;TD&gt;Date Submitted&lt;/TD&gt;
          &lt;TD&gt;&lt;input type="date" name="bday" /&gt;&lt;/TD&gt;
      &lt;/TR&gt;
      &lt;TR&gt;
          &lt;TD&gt;Requested by&lt;/TD&gt;
          &lt;TD&gt;&lt;INPUT type=text name="reqby" /&gt;&lt;/TD&gt;   
          &lt;TD&gt;priority&lt;/TD&gt;
          &lt;TD&gt;
              &lt;select name="priority"&gt;
                  ...
              &lt;/select&gt;
          &lt;/TD&gt;
      &lt;/TR&gt;
      &lt;TR&gt;
          &lt;TD&gt;Description Of Change:&lt;/TD&gt;
          &lt;TD&gt;&lt;textarea name="doc" id="doc" cols="25" rows="3"&gt;&lt;/textarea&gt;&lt;/TD&gt;
      &lt;/TR&gt;
      &lt;TR&gt;
          &lt;TD&gt;Bussiness Impact Of Change:&lt;/TD&gt;
          &lt;TD&gt; &lt;textarea name="boc" id="doc" cols="25" rows="3"&gt;&lt;/textarea&gt;&lt;/TD&gt;
      &lt;/TR&gt;
  &lt;/TABLE&gt;
  
  &lt;table class="dynatable1"&gt;
      &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Bussiness Process Impacted&lt;/th&gt;
                  &lt;th&gt;Tools Used / System Impacted&lt;/th&gt;
                  &lt;th&gt;Bussiness Driver description&lt;/th&gt;
                  &lt;th&gt;Impact category&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
  
          &lt;tbody&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;textarea name="v1" cols="30" row="1" id="demo3" value=""&gt;&lt;/textarea&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;textarea name="v2" cols="50" rows="2" id="demo1" value="" /&gt;&lt;/textarea&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;textarea name="v3" cols="50" rows="2" id="demo2" value="" /&gt;&lt;/textarea&gt;&lt;/td&gt;
                  &lt;td&gt;
                      &lt;select name="v4"&gt;
                          ...
                      &lt;/select&gt; 
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
  &lt;input name ="printbtn"  type="image" src="submit.jpg" class="submit" value="SUBMIT"  &gt;             
  &lt;/form&gt;
  </code></pre>
  
  <p>My PHP FILE IS AS FOLLOWS :</p>
  
  <pre><code>$dbhandle= mysql_connect($hostname,$username,$password) or die("Unable to connect to database");
  
  $selected = mysql_select_db("form",$dbhandle) or die("could not select the database");
  
  $val1 = $_POST['crno'];
  $val2 = $_POST['department'];
  $val3 = $_POST['bday'];
  $val4 = $_POST['reqby'];
  $val5 = $_POST['priority'];
  
  if(isset($_POST['doc']))
  {
      $dec_of_change = $_POST['doc'];
  }
  if(isset($_POST['boc']))
  {
      $bus_of_change = $_POST['boc'];   
  }
  if(isset($_POST['v1']))
  {
      $variable_string1 = $_POST['v1'];       
  }
  if(isset($_POST['v2']))
  {
      $variable_string2 = $_POST['v2'];
  }
  if(isset($_POST['v3']))
  {
      $variable_string3 = $_POST['v3'];       
  }
  if(isset($_POST['v4']))
  {
      $variable_string4 = $_POST['v4'];
  }
  
  if (
      $val2 == "" || 
      $val3 == "" || 
      $val4 == "" || 
      $val5 == "" || 
      $dec_of_change == "" || 
      $bus_of_change == "" || 
      $variable_string1 == "" || 
      $variable_string2 == "" || 
      $variable_string3 == ""
  ) {
      echo "Fill the entire form ";
      header("Location: fill.html"); 
      }
  
  else {
      $sql="  INSERT INTO     fill1 (
                                  department, date, reqby, 
                                  priority, doc, boc, 
                                  bpi, tu, bd, ic
                              )
              VALUES (
                                  '$val2', '$val3', '$val4', 
                                  '$val5', '$dec_of_change', '$bus_of_change',
                                  '$variable_string1', '$variable_string2', '$variable_string3', '$variable_string4'
                              )";
      $result=mysql_query($sql);
      header("Location: startpage.html");
  
  mysql_close($dbhandle);
  }
  </code></pre>