title: passing multiple checkbox values to controller
body: <p>I am developing a movie ticket reservation system in codeigniter.The user can select his seat by checking the box on each available seat.When I try to store the checked valued in session data i get an error.Below is my code.</p>
  
  <p>View select_seat</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;title&gt;Select Seats&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="http://localhost/cinema/assets/css/form2.css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method="post" action="http://localhost/cinema/Movies/select_combo" name="selectshow" accept-charset="utf-8" class="username"&gt;
  &lt;?php
  
  $prevRowId = null;
  $seatColor = null;
  $tableRow = false;
  //echo $result;
  echo "&lt;table width='100%' border='0' cellpadding='0' cellspacing='2'&gt;";
  foreach($query as $key=&gt;$result)
  {
    $rowId = $result['rowId'];
    $status = $result['status'];
    $columnId = $result['columnId'];
    $typeID=$result['seat_type_id'];
  if ($prevRowId != $rowId) {
   if ($rowId != 'A') {
    echo "&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;";
    echo "\n&lt;/tr&gt;";
  }
   $prevRowId = $rowId;
   echo "\n&lt;tr&gt;&lt;td align='center'&gt;&lt;table border='0' cellpadding='5' cellspacing='2'&gt;      &lt;tr&gt;";
   } else {
  $tableRow = false;
  }
   if ($status == 0) {
   if($typeID==1)   
      $seatColor = "grey";
   else if($typeID==2)
    $seatColor="yellow";
  else  
    $seatColor="white";
   } 
  else {
   $seatColor = "red";
  }
  
   echo "\n&lt;td bgcolor='$seatColor' align='center'&gt;";
   echo "$rowId$columnId";
   if ($status == 0)
  {
   echo "&lt;input type='checkbox' name='seats[]' value='$rowId$columnId'&gt;&lt;/checkbox&gt;";
  }
  echo "&lt;/td&gt;";
   if (($rowId == 'A' &amp;&amp; $columnId == 6)
     || ($rowId == 'B' &amp;&amp; $columnId == 7)
     || ($rowId == 'C' &amp;&amp; $columnId == 7)
      || ($rowId == 'D' &amp;&amp; $columnId == 7)
  ) {
  // This fragment is for adding a blank cell which represent the "center aisle"
  echo "&lt;td&gt; &lt;/td&gt;";
  }
   }
   echo "&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;";
   echo "&lt;/tr&gt;";
   echo "&lt;/table&gt;";
  
  mysql_close();
  ?&gt;
  &lt;input type="submit" class="button-link" style="float:right; margin-top: 20px; margin-right:0px; margin-bottom: 10px;" value="Submit" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Model</p>
  
  <pre><code> &lt;?php 
   class Selectseat extends CI_Model {
     public function __construct()
     {
        $this-&gt;load-&gt;database();
     }
  
     function get() {
        return $this-&gt;db-&gt;query("SELECT * from seats order by rowId, columnId asc")
               -&gt;result_array();
     }
   }
   ?&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code> function select_combo(){
         foreach($this-&gt;input-&gt;post('seats[]') as $seat)
              $data['seats']=$seat;
      $this-&gt;session-&gt;set_userdata($data);
  
         $this-&gt;load-&gt;model('combo_model');
      $data['combos'] = $this-&gt;combo_model-&gt;get_combo();
      $this-&gt;load-&gt;view('header');
         $this-&gt;load-&gt;view('select_combo',$data);
  
  
     }
  </code></pre>
  
  <p>I'm getting this error</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Warning
  
  Message: Invalid argument supplied for foreach()
  
  Filename: controllers/Movies.php
  </code></pre>