title: I want to submit this form into DB php
body: <p>i want to insert this below given form data to database, but i dont know how to do this, it is about inserting product to multiple warehouse with different quantities, when checkbox against the warehouse name is checked than the quantity textbox appears.</p>
  
  <p>and this is my PHP code</p>
  
  <pre><code>&lt;form name="form1" method="post" action="product_insert.php" enctype="multipart/form-data"&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;td width="274" align="right" height="25"&gt;&lt;strong&gt;Product Name :&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input type="text" name="wproname" value=""  /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td width="274" align="right" height="25"&gt;&lt;strong&gt;Select Warehouse :&lt;/strong&gt;&lt;/td&gt;
        &lt;td width="500"&gt;&lt;table style="border:none"&gt;
            &lt;tr &gt;
              &lt;td&gt; Select &lt;/td&gt;
              &lt;td&gt; Name &lt;/td&gt;
              &lt;td&gt; Quantity &lt;/td&gt;
            &lt;/tr&gt;
            &lt;?php 
      $sql="select * from tbl_warehouse where w_flag='1'"; 
      $result=ExecuteGetRows($sql);   
      $num_rows=count($result); ?&gt;
            &lt;?php for($i=0;$i&lt;$num_rows;$i++){ ?&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" name="chk&lt;?php echo $result[$i]['w_id'];?&gt;" value="&lt;?php echo $result[$i]['w_id'];?&gt;" id="chk&lt;?php echo $result[$i]['w_id'];?&gt;" onChange="display&lt;?php echo $result[$i]['w_id'];?&gt;();" /&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;?php echo $result[$i]['w_name'];?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="qty&lt;?php echo $result[$i]['w_id'];?&gt;" id="qty&lt;?php echo $result[$i]['w_id'];?&gt;" style="display:none" /&gt;
               &lt;/td&gt;
            &lt;/tr&gt;
            &lt;script&gt;
  function display&lt;?php echo $result[$i]['w_id'];?&gt;()
  {
  if(document.getElementById("chk&lt;?php echo $result[$i]['w_id'];?&gt;").checked)
  {
  
  document.getElementById("qty&lt;?php echo $result[$i]['w_id'];?&gt;").style.display="block";
  }
  if(!document.getElementById("chk&lt;?php echo $result[$i]['w_id'];?&gt;").checked)
  {
  document.getElementById("qty&lt;?php echo $result[$i]['w_id'];?&gt;").style.display="none";
  }
  }
  &lt;/script&gt;
            &lt;?php } ?&gt;
          &lt;/table&gt;&lt;/td&gt;
      &lt;/tr&gt;
         &lt;tr&gt;
        &lt;td align="right"&gt;&lt;/td&gt;
        &lt;td width="296"&gt;&lt;input type="submit" name="Submit" value="Add New" align="middle" class="button login_btn"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And I am using this php code for inserting data to the database</p>
  
  <pre><code>$sqls=mysql_query("select * from tbl_warehouse");
  while($result=mysql_fetch_array($sqls)) {
      $w = $result['w_id'];
  
      echo $_POST['chk'.$w];
  
      foreach($_POST['chk'.$w] as $key=&gt;$val) {
          echo $_POST['chk'.$w];
          $sql = "INSERT INTO tbl_product(p_id,w_id,p_name,p_qty) values ('','".$wid."','".$wproname."','".$qty."')"; 
  
          mysql_query($sql);  
      }
  }
  </code></pre>