0
I’m on a page where you’re printing out a menu. And underneath this data I want you to show me the ingredients of this menu, and I will search them from a list of ingredients.
Controller:
function lista_ingre()
{
    $this->load->model('ingredientes_model');
    $data['list'] = $this->ingredientes_model->getAllDisplayable_ing();
    //var_dump($data['list']); exit;
    $data['username'] = $this->session->userdata('username');
    $this->load->view('menus_detalhes_user',$data);
}   
Menu model:
function GetDisplayableByUsername_u($id)
{
    //indica os campos
    $this->db->select('id_menu, foto, nome, descricao, preco ');
    $result = $this->db->get_where('menus',array('id_menu' => $id));
    return $result->row();
}
Model of ingredients:
function getAllDisplayable_ing($id)
 {
    $this->db->select('id_ingrediente, lista_ingredientes.id_menu, nome_ingrediente, quantidade');
    $this->db->from('lista_ingredientes');
    $this->db->join('menus', 'menu.id_menu = lista_ingredientes.id_menu');
    $this->db->where('menu.id_menu', $id);
    $result = $this->db->get();
     return $result->result();
 }
Menu view:
     <p class="text-muted"><?php echo $menus->nome?></p>
 <p class="text-muted"><?php echo $menus->preco?>€</p>
View of the ingredients:
 <?php foreach ($list as $lista_igredientes): ?>
                <div class="service-box">
                    <img src="" class="img-responsive" alt="">
                    <h3><?php echo $lista_igredientes->nome_ingrediente?></h3>
                    <p class="text-muted"><?php echo $lista_igredientes->quantidade?></p>
                </div>
          <?php endforeach ?> 
Menu data appears well in the view, but ingredient data does not. The error is: Undefined variable: list and Invalid argument supplied for foreach()
Thank you
You are making a submenu menu from the database?
– Sr. André Baill