title: how to store loop textbox value in mysql database using array?
body: <p>i create the code for text box, date and drop down within for loop and try to store those values in my DB using array concept. i search some code for internet and but not working good for storing data. I'm a newbie to PHP. Any idea would be great.</p>
  
  <pre><code>&lt;?php                       
  for($i=1;$i&lt;=4;$i++)
  {
  ?&gt;
  &lt;tr&gt;
                          &lt;td&gt;Name&lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="col_name[&lt;?php echo $i;?&gt;]" value=""/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td &gt;Complete Address (Road Name, City, State, Country, Zip)&lt;/td&gt;
  &lt;td&gt;&lt;textarea name="add[&lt;?php echo $i;?&gt;]" value=""&gt;&lt;/textarea&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;td&gt; Date of birth(Ex.: mm-dd-yyyy)&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="dob[&lt;?php echo $i;?&gt;]" id="dob&lt;?php echo $i ;?&gt;" value=""/&gt;   
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Sex&lt;/td&gt;
  &lt;td&gt;&lt;input type="radio" name="col_certi[&lt;?php echo $i;?&gt;]" value="Yes"/&gt;&amp;nbsp;&amp;nbsp;Yes&amp;nbsp;
  &lt;input type="radio" name="col_certi[&lt;?php echo $i;?&gt;]" value="No"/&gt;&amp;nbsp;No
  &lt;/td&gt;
  &lt;tr&gt;
  &lt;td &gt;Country&lt;/td&gt;
  &lt;td&gt;&lt;select name="countryid[&lt;?php echo $i;?&gt;]"/&gt;
  &lt;option value=""&gt;Select&lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;File Upload&lt;/td&gt;
  &lt;td&gt;&lt;input type="file" name="col_certi_file[&lt;?php echo $i;?&gt;]" value="&lt;?php echo $fir_col_certi_file;?&gt;"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td align="center" colspan="4"&gt;&lt;hr color="#6699CC" width="90%"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;?php
  }
  ?&gt;
  </code></pre>
  
  <p>and i write the code for save the col_name data only using php</p>
  
  <pre><code>foreach($col_name as $colname)
  $updatecol="update education set col_name='$colname' where employee_id=".$ employee_id;
  if(!mysql_query($updatecol))
  </code></pre>
  
  <p>here the $colname last value only store in the database.. i want to store 4 value in database.. how to do it.</p>