Welcome Guest, Not a member yet? Register   Sign In
Nested Loop
#1

[eluser]james182[/eluser]
how would you go about changing this to a codeIgniter styled controller function?
Code:
function get_nav($current_parent_id, $current_child_id){
        $nav = '';        
        $sql = "SELECT * FROM tbl_nav WHERE nav_parent_id = 0 ORDER BY nav_order ASC";
        $result = mysql_query($sql) or die (mysql_error());
        
            while($r = mysql_fetch_assoc($result)):
            
                // Parent
                $current = $current_parent_id == $r['nav_id'] ? 'current' : '';
                
                $nav .= '<li><a >get_site_url().'/'.$r['nav_item_key'].'/'.$r['nav_id'].'" class="'.$current.'">'.$r['nav_item'].'</a>';
                
                $child_nav = mysql_query('SELECT * FROM tbl_nav WHERE nav_parent_id = '. $r['nav_id'] .' ORDER BY nav_order ASC');
            
                $nav .= '<ul>';
                while($child = mysql_fetch_assoc($child_nav)):
                    // Child
                    $current_child = $current_child_id == $child['nav_id'] ? 'current' : '';
                    
                    $nav .= '<li><a >get_site_url().'/'.$r['nav_item_key'].'/'.$child['nav_parent_id'].'/'.$child['nav_item_key'].'/'.$child['nav_id'].'" class="'.$current_child.'">'.$child['nav_item'].'</a></li>';
                endwhile;
                $nav .= '</ul>';
                    
            $nav .= '</li>';
        endwhile;    
    
        return $nav;    
    }
#2

[eluser]InsiteFX[/eluser]
Maybe you should read the CodeIgniter Users Guide first!

MVC Controllers, Views and Database sections.

InsiteFX
#3

[eluser]james182[/eluser]
Could some one point me in the right direction ?

i just want to display my 2 level menu




Theme © iAndrew 2016 - Forum software by © MyBB