![]() |
multiple query and foreach loop - 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 query and foreach loop (/showthread.php?tid=60008) |
multiple query and foreach loop - El Forum - 12-27-2013 [eluser]forzaferrari87[/eluser] Hallo, I am a newbie at CodeIgniter and want to know how does something. I have two tables. One of the is a category table and the other a normal one for informations. In my case I want to print out first the category with a foreach loop. That works. But in my second query I want to print out the information with the correct category. Without a framework I did this by a second foreach loop. My question. How I can print out the second table throught the id of the category table? Also I am searching at Google too, but I don't found the correct solution till now. multiple query and foreach loop - El Forum - 12-27-2013 [eluser]CroNiX[/eluser] This is a SQL issue, not framework. Check out JOINs. You can get categories and information from separate tables with a single query. multiple query and foreach loop - El Forum - 12-27-2013 [eluser]CroNiX[/eluser] client -id -name projects -id -client_id -description Code: SELECT client.name, projects.description will list each client name along with all of their project descriptions multiple query and foreach loop - El Forum - 12-27-2013 [eluser]forzaferrari87[/eluser] [quote author="CroNiX" date="1388161737"]client -id -name projects -id -client_id -description Code: SELECT client.name, projects.description will list each client name along with all of their project descriptions[/quote] Your SQL query is right, but I want it to do with where, because my target in the viewis this Code: <?php foreach($cats as $cats_item): ?> i think this i can only make with where or there are another solution in codeigniter for printing out a category loop and into this one a link loop? multiple query and foreach loop - El Forum - 12-27-2013 [eluser]CroNiX[/eluser] Code: $data = $this->db View: Code: $last_client = null; |