Running a db query then running another query |
[eluser]the future darlo manager[/eluser]
Hi, I am trying to create a basic site map. Basically it should show each of the main menu items and then underneath each of them the sub navigation for that particular section. I have created something which works in standard php but haven't a clue how to put it together in the Codeigniter MVC framework. Anyone willing to shed any light on this? Code: require_once ('html/php_includes/mysql_connect.php'); //Links to the database connection settings
[eluser]pistolPete[/eluser]
Use the database class. Use the MVC approach. Watch the video tutorials: http://codeigniter.com/tutorials/
[eluser]the future darlo manager[/eluser]
I know the basics but I'm struggling with running a query then another straight after its done whilst running through a loop.
[eluser]xwero[/eluser]
Code: $query = $this->db->query("SELECT * FROM cacdp_menu_groups WHERE display_on_site = 'Y' ORDER BY list_order");
[eluser]the future darlo manager[/eluser]
Right I've been trying to think about this but don't think I'm any closer to solving it. I have two models (one for my menu groups and one for the sub menu navigation). Code: class Menu_groups_model extends Model{ Code: class Sub_navigation_model extends Model{ I also have my sitemap function in controller.... Code: function sitemap() Basically I want to end up with something like this below... Main navigation link no 1 -Sub navigation for that group -Sub navigation for that group Main navigation link no 2 -Sub navigation for that group -Sub navigation for that group Obviously I need to loop through each of the main group records to get my top links. This will give me the correct order they are in (list_order sort) and then loop through the sub navigation ones. However this is where I am getting unstuck. I think I need to put all the sub navigation records into one big array so I can work with them in the view but I'm not too sure how to do it. This is probably the trickiest thing I've done yet in CI. Nothing has caused me this much grief. |
Welcome Guest, Not a member yet? Register Sign In |