title: I want to save all the checkbox values I select
body: <p>I m trying to store checkbox value subject_id but when i store this value to database it just store the last selected checkbox inside the database... please help me to sort out the code so I can get all selected values.</p>
  
  <p>I want to save all the checkbox values I selected,but if I check more then one checkbox it always save the last checkbox.</p>
  
  <pre><code> function get_class_section($day='',$section='',$class='')
  {
  
      print_r($section);
      $sections = $this-&gt;db-&gt;get_where('class_routine' , array(
          'day' =&gt; $day,'section_id'=&gt;$section,'class_id'=&gt;$class
      ))-&gt;result_array();
  
  
      foreach ($sections as $row) {
  
  
      echo "&lt;table class=\"table table-bordered datatable\" id=\"table_export\"  &gt;";
  
      echo "&lt;thead&gt;";
      echo "&lt;th&gt;Subject&lt;/th&gt;&lt;th colspan=\"2\"&gt;status&lt;/th&gt;";
      echo "&lt;/thead&gt;";
  
      echo "&lt;tbody&gt;";
      echo "&lt;tr&gt;";
  
      echo "&lt;td&gt;". $this-&gt;crud_model-&gt;get_subject_name_by_id($row['subject_id'],"&lt;input type=\"text\"  name=\"subject_id\" value=\"subject_id\" &gt;");
      echo "&lt;input type=\"checkbox\" name=\"types[]\"  value=\"".$row['subject_id']."\" set_checkbox('types[]', 'subject_id')&gt;";
  
        echo "&lt;/td&gt;";
  
      echo "&lt;td&gt;present&amp;nbsp;&amp;nbsp;&lt;input type=\"checkbox\"  value=\"1\" &gt;&lt;/td&gt;"
        . "&lt;td&gt;Absent&amp;nbsp;&amp;nbsp;&lt;input type=\"checkbox\" name=\"types[]\" value=\"0\"&gt;&lt;/td&gt;";
  
  
  
      echo "&lt;/tr&gt;";
      echo "&lt;/tbody&gt;";
  
      echo "&lt;/table&gt;"; 
  
  
  
  
      }
  
  }
  </code></pre>
  
  <p>how to save all the check-boxes that i selected </p>