how to insert an hidden field value along side with a checkbox in to the database
<p>i am new here but i have a problem in inserting the id and the value of the checkboxes into my database here is the code of the form:</p>

<pre><code>  &lt;?php

 include('db.php');

 $sql = "select * from sheet1 order by course_level asc";
 $r = mysqli_query($dbc,$sql) or die(mysqli_error($dbc));
$co = '';
while($row = mysqli_fetch_array($r)) {
$co .= '&lt;tr&gt;&lt;td&gt;'.$row['course_level'].'&lt;/td&gt;&lt;td&gt;&lt;input name="courses[]"
  type= "checkbox"    value   =    "'.$row['course_code'].'"&gt;'.$row['course_code'].'
&lt;/td&gt;       &lt;td&gt;'.$row['course_title'].'&lt;/td&gt;&lt;td&gt;'.$row['course_lecturer'].'
 &lt;/td&gt;&lt;input   type=hidden    name=cid[] value="'.$row['cid'].'"&gt;
 &lt;/tr&gt;';

  }

 ?&gt;
</code></pre>

<p>And this is the action code:</p>

<pre><code>    &lt;?php
   include('db.php');
  if(isset($_POST['courses']))
   echo 'lie';
   else
  echo 'true';
  foreach($_POST['courses'] as $row=&gt;$id){

  $courses=$id;
  $cid = $_POST['cid'][$row];
  $sql = "insert into selected_courses values ('','$courses','$cid')";
  $r = mysqli_query($dbc,$sql);
  }
  if($r)
  echo 'done';
  ?&gt;
</code></pre>

<p>thanks a lot.</p>
