title: php : my foreach loop checkbox did not send value properly
body: <p>My problem with the checkbox is , it didn't send the value as i want.. </p>
  
  <p>This is my html code for the checkbox . I use foreach loop. </p>
  
  <pre><code>&lt;form id="signupform" autocomplete="off" method="post" action="inputchecklist.php" class="form_container left_label"&gt;
  &lt;?php 
  $ew = mysql_query("select * from pos_unit where pos_unit_name like '%Director%'");
  $row = mysql_num_rows($ew);
  while($eq = mysql_fetch_array($ew))
  {
  $pos = $eq['pos_unit_name'];
  $checklist = mysql_query("select * from checklist where check_pos = '$pos' and check_ok = 'Check'");
  $excheck = mysql_fetch_array($checklist);
  $poss = $excheck['check_pos'];
  ?&gt;
  &lt;li&gt;
  &lt;div class="form_grid_12"&gt;
  &lt;label class="field_title" &gt;&lt;?php echo $eq['pos_unit_name']; ?&gt;&lt;/label&gt;
  &lt;div class="form_input"&gt;
  &lt;input name="check[]" class="checkbox" type="checkbox"  value="&lt;?php echo $eq['pos_unit_name']; ?&gt;" style="opacity: 0;"&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/li&gt;
  &lt;?php } ?&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and this is the php code for insert..</p>
  
  <pre><code>&lt;?php 
  
  include 'config.php';
  
  $code = $_POST['code'];
  
  $targ = $_POST['selectdistarg'];
  
  $check = $_POST['check'];
  $pos = $_POST['pos'];
  
  
  foreach($pos as $index =&gt; $names)
  {
      $insert = mysql_query("insert into checklist (check_ok,check_pos,check_code) values ('$check[$index]','$names','$code')") or die (mysql_error());
  }
  
  $update = mysql_query("update corporate_kpi set kpi_dist_targ = '$targ' where kpi_code = '$code'");
  
  ?&gt;
  </code></pre>
  
  <p>For example, </p>
  
  <p>Checkbox 1 - A,
  Checkbox 2 - B,
  Checkbox 3 - C</p>
  
  <p>If we choose number 2, value is B, but my code is, if we choose number 2, the value is A and if we choose number 3, the value is also A, i don't know why.. </p>
  
  <p>This is the <code>&lt;th&gt;</code> that generate based on db</p>
  
  <pre><code>&lt;?php 
  while ($eq = mysql_fetch_array($ew))
  {
  $pos = $eq['emp_data_pos'];
  ?&gt;
  &lt;th&gt;&lt;?php echo $eq['emp_data_pos']; ?&gt;&lt;/th&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>and this is the <code>&lt;td&gt;</code> value..</p>
  
  <pre><code>&lt;?php $qq = mysql_query("select emp_data_pos from emp_data where emp_data_pos like '%Director%'");
  while ($ee = mysql_fetch_array($qq))
  {
  $pos = $ee['emp_data_pos'];
  $pos1 = mysql_real_escape_string($pos);
  $aa = mysql_query("select * from checklist where check_pos = '$pos1' and check_code = '$code' and check_ok = 'Check'");
  $bb = mysql_fetch_array($aa);
  $ok = $bb['check_ok'];
  if($ok != "")
  {
  $ok = '&amp;#10004;';
  } else {
  $ok = '';
  }
  ?&gt;
  &lt;td class="center"&gt;
  &lt;?php echo $ok; ?&gt;
  &lt;/td&gt;
  &lt;?php } ?&gt;
  </code></pre>