Welcome Guest, Not a member yet? Register   Sign In
Running a db query then running another query
#1

[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

$group_id = 6;

//Sets the page title
$content[content_title] = "Site Map";
    
include('html/header.inc'); //Loads the header file

//Starts to load the content
echo "<div id=\"full_width_container\" class=\"page\">";
echo "<h1>Site Map</h1>";
echo "<p>You can use the site map below to find information on the website.</p>";

$main_menu_query = "SELECT * FROM cacdp_menu_groups WHERE display_on_site = 'Y' ORDER BY list_order";
$main_menu_result = @mysql_query ($main_menu_query);
$number_of_menus = mysql_num_rows ($main_menu_result);

//If the number of is greater then zero display each top level menu element
if ($number_of_menus > 0) {
    while ($main_menu = mysql_fetch_array($main_menu_result, MYSQL_ASSOC)) {
    
        //Finds out if the page is linking to a url or a page id
        if ($main_menu[use_url] == 'Y') {
            echo "<p><a >$main_menu[long_group_name]</a></p>";
        } else {
            echo "<p><a >$main_menu[long_group_name]</a></p>";
        }    
        
        $sub_menu_query = "SELECT * FROM cacdp_sub_navigation WHERE group_id = $main_menu[group_id] AND display_on_site = 'Y' ORDER BY list_order";
        $sub_menu_result = @mysql_query ($sub_menu_query);
        // Finds out how many permission records have been found
        $number_of_sub_menus = mysql_num_rows ($sub_menu_result);
        
        if ($number_of_menus > 0) {
        echo "<ul>";
            while ($sub_menu = mysql_fetch_array($sub_menu_result, MYSQL_ASSOC)) {
                if ($sub_menu[use_url] == 'Y') {
                    echo "<li><a >$sub_menu[sub_nav_name]</a></li>";
                } else {
                    echo "<li><a >$sub_menu[sub_nav_name]</a></li>";
                }
            }
        echo "</ul>";
        }
            
    }
} else {
    echo "<p>No sections found</p>";
}

echo "<p></p>
</div>";
//End of content
    
include('html/php_includes/loadmenu.php'); //Loads the menu
include('html/footer.inc'); //Loads the footer file


Messages In This Thread
Running a db query then running another query - by El Forum - 03-03-2009, 07:51 AM
Running a db query then running another query - by El Forum - 03-03-2009, 07:59 AM
Running a db query then running another query - by El Forum - 03-03-2009, 08:08 AM
Running a db query then running another query - by El Forum - 03-03-2009, 08:16 AM
Running a db query then running another query - by El Forum - 03-04-2009, 07:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB