title: Looping through an array of checkbox
body: <p>I have a form with rows which are populated from a table. Each row has a "checkbox" which the user can check or not.</p>
  
  <p>When the form is submitted I want to be able to read which checkbox have been selected and insert the result in to a data table.</p>
  
  <p>My code so far
  FORM:</p>
  
  <pre><code>&lt;form method="post" name="form1" action="&lt;?php echo $editFormAction; ?&gt;"&gt;
  &lt;table
  &lt;?php do { ?&gt;
  &lt;tr&gt;
  &lt;td&gt;input type="text" name="InspectRoomNo" value="&lt;?php print $row_InspectItems['AuditItemNo']; ?&gt;"&gt;&lt;/td&gt;
  &lt;td&gt;php echo $row_InspectItems['AuditItem']; ?&gt;td&gt;
  &lt;td&gt;input name="check[]" type="checkbox"  &gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;?php } while ($row_InspectItems = mysql_fetch_assoc($InspectItems)); ?&gt;
  &lt;input type="submit" value="Insert record"&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>The insert: fetchs $Items from table</p>
  
  <pre><code>while($row = mysql_fetch_assoc($Items))
  {
  $array[] = $row['AuditItem'];
  }
  
  
  foreach($array as $id) {
  $AuditItemID = mysql_real_escape_string($id);
  
  if(isset($_POST['check'])){
  $Checked = mysql_real_escape_string($_POST['check'][$row]);
  }
  }
  </code></pre>
  
  <p>The problem I am having is the returned values for all the checkbox is true, even if a checkbox was not selected.</p>
  
  <p>Can anyone help me sort this issue.</p>
  
  <p>Many thanks.</p>