How to send array from view to model - 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 send array from view to model (/showthread.php?tid=70808) |
How to send array from view to model - Kennyendowed - 06-02-2018 how to submit a form containing an array in codeigniter <form method="post" action="collect_vals.php"> <div><input type="text" name="mytext[]"></div> </div> </form> RE: How to send array from view to model - ciadmin - 06-02-2018 This is not properly a CodeIgniter problem, but more a general PHP question. See - https://www.w3schools.com/php/php_forms.asp - https://stackoverflow.com/questions/3314567/how-to-get-form-input-array-into-php-array - http://comp4711.jlparry.com/display/lesson/basic04-handling RE: How to send array from view to model - Kennyendowed - 06-03-2018 Am not sure u understand my question Here the error am having anyway this my error A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: database/DB_query_builder.php Line Number: 683 Backtrace: File: /var/www/html/esurf/application/models/Bs_admin_model.php Line: 482 Function: where File: /var/www/html/esurf/application/controllers/hod/Users.php Line: 407 Function: get_all_course_assign_by_search File: /var/www/html/esurf/index.php Line: 316 Function: require_once RE: How to send array from view to model - ciadmin - 06-03-2018 Your original post made no mention of an error. From the backtrace, it looks like line 482 in Bs_admin_model.php is calling the query builder's where() with one of the arguments being an array when a string is expected. RE: How to send array from view to model - Kennyendowed - 06-03-2018 I know that I told u Am passing an array variable to my model That y I ask for help on the proper way to pass array data in codeigniter RE: How to send array from view to model - InsiteFX - 06-03-2018 The Query Builder where expects a string as admin said, if you want to pass an array you need to assign the array index that you want to use in the where clause to a string property and then use it in the where clause. PHP Code: foreach($_POST["array_name"] as $key => $value) RE: How to send array from view to model - Kennyendowed - 06-03-2018 (06-03-2018, 03:49 AM)InsiteFX Wrote: The Query Builder where expects a string as admin said, if you want to pass an array Ok I give it a try |