Showing data in a loop, view, controller, model |
[eluser]blitzneo[/eluser]
I have a simple database, with 2 tables. One for brand, the other for model, having cars as examples. In my model I have 2 functions, one to get all brands, and one to get all models from a brand. This way: Code: public function get_brands() Both working perfectly, so my question is, how can I get in a view something like brand-1: - model1 - model2 - model3 brand-2: - model1 - model2 etc. Sorry if it is a too easy question, but I am just trying to learn. I am using a foreach loop btw. This is the view. Code: BRANDS: Any help will be great =) Thanks for your time
[eluser]SitesByJoe[/eluser]
You need to do something like this: Code: <?php
[eluser]SitesByJoe[/eluser]
And you don't need the result() portion of my snippet.
[eluser]blitzneo[/eluser]
Code: <?php "Invalid argument supplied for foreach()" It cannot be merged like you commented or am I missing something ? Thanks!
[eluser]shailendra[/eluser]
Please check this link http://ellislab.com/forums/viewthread/193763/#916973
[eluser]SitesByJoe[/eluser]
Try this code: Code: $brands = $this->db->get('brands');
[eluser]blitzneo[/eluser]
Very interesting post =) I will be using Joe's suggestion for now. I will check performance in a future 'upgrade' of the webapp. Thanks guys. |
Welcome Guest, Not a member yet? Register Sign In |