![]() |
how to input multiple values and data at the same time ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: how to input multiple values and data at the same time ? (/showthread.php?tid=72513) |
how to input multiple values and data at the same time ? - keishaadora - 01-01-2019 So i have a problem with many to many relationship. Currently i have "surat" and "surat_user" table. How do i insert data into surat and at the same time insert multiple values from select2 multiple form into surat_user table ? and how to get data so i can update it. I've seen some of other similar question but none of them suitable for my problem. I've tried using foreach to store the multiple values but it doesn't work With these codes below i get some error when i tried to input data "Object of class CI_DB_mysqli_result could not be converted to string" "Array to string conversion" "Cannot add or update a child row: a foreign key constraint fails" Model: Code: var $table='surat'; View: Code: <label class="control-label col-lg-2">Disposisi</label> Controller : Code: class SuratMasuk extends CI_Controller { RE: how to input multiple values and data at the same time ? - Pertti - 01-02-2019 PHP Code: $id_surat = $this->db->query('SELECT surat.id_surat FROM surat ORDER BY id_surat DESC limit 1'); I think you expect both these to return single value, I'm pretty sure both, or at least first, is returning either array or DB query result object. For first line, you probably want to do something like this: PHP Code: $id_surat = $this->db->query('SELECT surat.id_surat FROM surat ORDER BY id_surat DESC limit 1')->first_row()->id_surat ; |