![]() |
Helper Issue - 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: Helper Issue (/showthread.php?tid=50043) Pages:
1
2
|
Helper Issue - El Forum - 03-12-2012 [eluser]james182[/eluser] OK, so i am having issues getting this to work, it shows the first but that's it. SOLVED Helper Issue - El Forum - 03-12-2012 [eluser]InsiteFX[/eluser] It's not a helper issue look at your code your returning ->row which is only one record... Which makes your foreach loop in the view useless! Helper Issue - El Forum - 03-12-2012 [eluser]james182[/eluser] How should it be ?? I have tried using ->row(); ->result(); ->result_array(); i just want to return the name of the products in the loop Helper Issue - El Forum - 03-12-2012 [eluser]Aken[/eluser] You should just join the product data onto whatever query is returning the ordered items list. Doing it your way is a lot of unnecessary overhead. Helper Issue - El Forum - 03-12-2012 [eluser]Matalina[/eluser] [quote author="InsiteFX" date="1331558959"]It's not a helper issue look at your code your returning ->row which is only one record... Which makes your foreach loop in the view useless! [/quote] The foreach loop is not useless it's looping through another variable to get the id of the item. Try ->row(0) if that doesn't work try setting the query ->row() to a variable and returning that. Helper Issue - El Forum - 03-12-2012 [eluser]InsiteFX[/eluser] It doe's when he is only returning a row! Because all he will get is one record... Helper Issue - El Forum - 03-12-2012 [eluser]Aken[/eluser] That's all he WANTS is one record... He isn't looping the results of this function, he's using this function in a loop... Still, you should fetch this data in a better way - doing separate queries for each title is a lot of extra work. You should show more about where you're getting the data you are looping through, and how you can add titles to that instead. Helper Issue - El Forum - 03-12-2012 [eluser]CroNiX[/eluser] if your loop is only going through one cycle, check the data you are looping over ($order->ordered_items). It could be that there is only one row there, but you don't show any code on how you get $order (referred to only in your view), so we can't tell. Helper Issue - El Forum - 03-12-2012 [eluser]james182[/eluser] Ok thanks so far. Here is more info, i am looping through the data to output orders and each ordered item associated with that order. so for example: Order A - Show Product A, Product B, Product C Order B - Show Product A [solved] Helper Issue - El Forum - 03-12-2012 [eluser]Aken[/eluser] Post this model function: Code: $order->ordered_items = $this->orders_m->get_ordered_items($order->id); You should be able to modify this function to include the title, so you don't need to do any additional logic elsewhere to get it. |