![]() |
Multiple Foreach Loops - 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: Multiple Foreach Loops (/showthread.php?tid=31325) |
Multiple Foreach Loops - El Forum - 06-15-2010 [eluser]Timothy_[/eluser] Hello, This is a situation I have found myself in a few times and I just want clear it up once and for all. Best just to show you what I need to do in some example code. My Controller Code: function my_controller() Code: <?php if($get_cue_sheets->result_array()) { ?> So basically I am trying to display a number of sheets and then within each of those sheets the clips that belong to that sheet. I hope this makes sense to someone out there. Thanks, Tim Multiple Foreach Loops - El Forum - 06-15-2010 [eluser]mddd[/eluser] It's not efficient to look up the clips for every sheet separately. Use a JOIN query to get both lists at the same time. Code: // get the data Now in your view you can loop through the sheets, and within that, loop through the clips: Code: foreach($data as $sheet) { |