How to batch insert multiple rows with different data - 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 batch insert multiple rows with different data (/showthread.php?tid=70572) |
How to batch insert multiple rows with different data - lnzbuyao - 04-28-2018 Hello! Can someone help me out? I'm trying to batch insert into my sponsors table. I have visited multiple help sites, but none of their solutions seem to work on mine. I'm trying to input the following: sponsor_id - PK (AUTO_INCREMENT) firstname middlename lastname baptism_id - FK Here's my code for the VIEW PHP Code: <div class="tab-pane" id="tab5"> Oh yeah, also, my textboxes are generated based on the number selected by the user. It is done by Javascript. Here's the code for that as well. Code for TEXTBOX GENERATION via Javascript PHP Code: $("#txtboxnum").change(function(e) { Here's my code for the CONTROLLER PHP Code: $size = $this->input->post('txtboxnum'); Here's for my MODEL PHP Code: function insert_sponsors($sponsors){ Any help is very much appreciated! Thank you! RE: How to batch insert multiple rows with different data - Wouter60 - 04-28-2018 In your controller, temporarily insert these lines after $data = $this->input->post('sponsor'); PHP Code: echo '<pre>'; I guess one the elements in this array is "txtboxnum". Does your database table have a field with that name? If not, insert_batch won't be able to insert the records. RE: How to batch insert multiple rows with different data - lnzbuyao - 04-29-2018 No txtboxnum is not a field in my database. I will try your suggestion and then report back what happens. |