Codeigniter - passing multiple data arrays to a view? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Codeigniter - passing multiple data arrays to a view? (/showthread.php?tid=31571) |
Codeigniter - passing multiple data arrays to a view? - El Forum - 06-24-2010 [eluser]design_shuffle[/eluser] Hi, I am trying to populate a dropdown menu on an events page with a list of locations. What I wish to do is retrieve all names from a locations table, store them in an array in my event.php controller, pass this to a view which then lists all the locations in a dropdown menu. Here is the loop in my controller which retrieves the locations.. Code: $result = $this->locationModel->get_locations_list(); I am already passing a variable to my view called $data like so - Code: $this->template->load('admin/template', 'admin/eventEdit', $data); I have tried passing the $arr variable and the $data array in the above line but this stops the view from rendering. Please could someone guide me on how to pass the information that is stored in the $arr variable to my view along with the $data variable. Thanks Dan Thanks Dan Codeigniter - passing multiple data arrays to a view? - El Forum - 06-24-2010 [eluser]Simian Studios[/eluser] Hi Dan $data should just be an array, so this should work: Code: $data['arr'] = $arr; Then in your view you would access $arr via "$data['arr']" and treat it just like a normal array. I would suggest giving $arr a more descriptive name also, just to avoid confusion further down the line.. |