Welcome Guest, Not a member yet? Register   Sign In
query problem
#6

[eluser]Bigil Michael[/eluser]
i have solved up to 2 level like this.
controller
Code:
$build_array = array();
  $parent = $this->Menus_model->get_parent_menu();    
  foreach($parent as $row){
    $build_array[] = array(
     'parent_array' => $row,
     'child_array' => $this->Menus_model->get_child_menu($row['id'])  
    );    
   }  
  $data['all_menu'] = $build_array;

model

Code:
function get_parent_menu(){    
     $this->db->where('parent', 0);
     $this->db->where('status',1);
     $this->db->select('id,parent,menu_name');
     $this->db->from('menus');
     $result = $this->db->get();
     return $result->result_array();
    }

   function get_child_menu($id){    
     $this->db->where('parent', $id);
     $this->db->where('status',1);
     $this->db->select('id,parent,menu_name');
     $this->db->from('menus');
     $result = $this->db->get();    
     return $result->result_array();
    }
view
Code:
<?php foreach($all_menu as $mn){?>  
<?php echo $mn['parent_array']['menu_name'];?>
  <?php  foreach ($mn['child_array'] as $row) { ?>        
   &lt;?php echo $row['menu_name']?&gt;</option>
  &lt;?php } ?&gt;
&lt;?php } ?&gt;

from this code i can print main menu and sub menu. but i have to print sub of sub menu also.
can any one help me to modify this code.


Messages In This Thread
query problem - by El Forum - 02-20-2014, 02:44 AM
query problem - by El Forum - 02-20-2014, 07:14 AM
query problem - by El Forum - 02-20-2014, 07:57 AM
query problem - by El Forum - 02-21-2014, 12:31 PM
query problem - by El Forum - 02-21-2014, 10:17 PM
query problem - by El Forum - 02-25-2014, 11:40 PM
query problem - by El Forum - 02-26-2014, 10:15 PM
query problem - by El Forum - 02-27-2014, 05:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB