title: Codeigniter delete multiple rows with checkboxes
body: <p>I'm trying to delete multiple private messages from my database by selecting multiple checkboxes in the inbox and clicking submit to delete. I have the code below but nothing happens. I'm not sure what I'm missing..</p>
  
  <p>View:</p>
  
  <pre><code>&lt;?php echo form_open('pm/remove_checked'); ?&gt;
  
  &lt;?php foreach ($query as $row): ?&gt;   
      &lt;input type="checkbox" name="msg[]" value="&lt;?php echo $row-&gt;id; ?&gt;" /&gt;
      &lt;?php echo $row-&gt;from; ?&gt;
      &lt;?php echo $row-&gt;subject; ?&gt;    
      &lt;?php echo date("m/d/Y",strtotime($row-&gt;msg_date)); ?&gt;          
  &lt;?php endforeach; ?&gt;
  
  &lt;?php echo form_submit('delete', 'Delete'); ?&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>function remove_checked()
  {
          //validation rules
          $this-&gt;form_validation-&gt;set_rules('msg[]', 'Private Message', 'required|xss_clean'); 
  
          if ($this-&gt;form_validation-&gt;run() == FALSE) 
          {
              $data['query'] = $this-&gt;Pm_model-&gt;received_msg(); 
              $this-&gt;load-&gt;view('pm/inbox', $data);   
          }
          else //success
          {
              $checked_messages = $this-&gt;input-&gt;post('msg'); //selected messages
              $this-&gt;Pm_model-&gt;delete_checked($checked_messages);
  
              //redirect to inbox                                     
          }
  
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>function delete_checked($checked_messages) 
  {
      $checked_messages = array();
      foreach ($checked_messages as $msg_id):
  
            $this-&gt;db-&gt;select('id');
            $this-&gt;db-&gt;from('user_msg');
            $this-&gt;db-&gt;where('id', $msg_id);
            $this-&gt;db-&gt;limit(1);
            $query = $this-&gt;db-&gt;get();
  
            if ($query-&gt;num_rows() &gt; 0) //if message exists
            {             
              $this-&gt;db-&gt;where('id', $msg_id);
              $this-&gt;db-&gt;where('recipient', $this-&gt;users-&gt;get_user_id()); //verify if recipient id is equal to logged in user id
              $this-&gt;db-&gt;delete('user_msg');
  
            }
            else 
            {
                  return FALSE;
            } 
  
      endforeach;
  }
  </code></pre>