samedi 22 septembre 2018

Pass array from checkboxes and insert multiple rows to database CodeIgniter

Here is my view:

<?php foreach ($list_peserta as $show): ?>
                <label>
                <input type="checkbox" name="undangan[]" value="<?php echo $show->email ?>" />
                <?php echo $show->nama ?></label>
              <?php endforeach; ?>
            </div>
          </div>
          <div class="form-actions">
            <input type="submit" value="Kirim" class="btn btn-info">
          </div>
          <?php echo form_close(); ?>

My Controller:

$data   =   array();
        $count  =   count($this->input->get_post['undangan']);
        for ($i = 0; $i <= $count ; $i++) {
            $data[] =   array(  
                                'id_acara'      =>  $this->input->post['id'][$i],
                                'email_peserta' =>  $this->input->post['undangan'][$i],
                                'status'        =>  ['Diundang'][$i]
                            );

            $this->db->insert_batch('kehadiran', $data);

I'm getting this error: enter image description here

Please help!




Aucun commentaire:

Enregistrer un commentaire