[SOLVED]Newbie question: Create a Multi-Dimensional Array - 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: [SOLVED]Newbie question: Create a Multi-Dimensional Array (/showthread.php?tid=35769) |
[SOLVED]Newbie question: Create a Multi-Dimensional Array - El Forum - 11-10-2010 [eluser]Juan Velandia[/eluser] Hello everyone, I've been dealing with this with little progress, I hope you can help: I get data with the following model Code: function get_section_articles() and I would like to arrange this data in a multidimensional Array something like this: Code: $section = array( I have a database where, 'Clients', 'Services','Techonologies' are in the section Table each one with it's id_section, and, 'pepsi', 'cocacola', 'sevenup', Web Design','Graphic Design', 'Data Migration','codeigniter','postgresql', 'ubuntu' are in the article table wich have a id_section column. I hope I've been clear, thanks in advance! [SOLVED]Newbie question: Create a Multi-Dimensional Array - El Forum - 11-10-2010 [eluser]smilie[/eluser] It's late here, can't think properly. But wanted to give you one advise regarding DB structure and naming convention. Make every single field name in all of your tables and databases unique. What I see now is that you have: Table cms_section, field name; Table cms_article, field name; So, when you do SQL queries, you must specify table name and field name. In this case: Table cms_section, field section_name; Table cms_article, field article_name; MySQL recognizes that both field names are unique and does not require you to specify table, so: $this->db->select('article_name,section_name'); will be sufficiant for MySQL to perform query :-) Good luck! Cheers, Smilie [SOLVED]Newbie question: Create a Multi-Dimensional Array - El Forum - 11-10-2010 [eluser]Juan Velandia[/eluser] Thanks mate, I will have this in mind! [SOLVED]Newbie question: Create a Multi-Dimensional Array - El Forum - 11-10-2010 [eluser]Juan Velandia[/eluser] After some hours dealing with this and with some previous threads I came up with he solution Model Code: function get_section_articles() controller Code: $data['section_articles'] = $this->section_content_model->get_section_articles(); view: Code: foreach ($section_articles as $section): ?> [SOLVED]Newbie question: Create a Multi-Dimensional Array - El Forum - 09-14-2012 [eluser]VolkS[/eluser] Thanks Juan Velandia !!! |