I have the following error in codigniter

0

I have an error, I'm calling data from the database to show them in two dropdown, first I get the data I have in the table, with the second I wanted to do the same as the first one and it gave me the following error

Severity: Notice

Message: Undefined variable: subgrupo

Filename: Inventario/catalogo.php

Line Number: 29

Backtrace:

File: C:\xampp\htdocs\sgis\application\views\Inventario\catalogo.php
Line: 29
Function: _error_handler

File: C:\xampp\htdocs\sgis\application\controllers\Catalogo.php
Line: 22
Function: view

File: C:\xampp\htdocs\sgis\index.php
Line: 315
Function: require_once 

This view:

<div id="contenido" class="container-fluid mt-3">
    <?php 
    $grupos = array('name'=>'grupo','class'=>'browser-default custom-select','id'=>'grupo');
    $subgrupos = array('name'=>'subgrupo','class'=>'browser-default custom-select','id'=>'subgrupo');
    ?>

    <div class="form-group">
        <div class="row">
            <div class="col-md-6">
                <div class="btn-group b" role="group">
                    <button type="button" class="btn btn-outline-success" onclick="agregar()">Nuevo Catalogo</button>
                    <button type="button" class="btn btn-outline-secondary" onclick="editar()">Editar</button>
                    <button type="button" class="btn btn-outline-primary" onclick="eliminar()">Eliminar</button>
                </div>
            </div>

        </div>

        <div class="row mt-2">
            <label class="col-md-1 mt-2">Grupos:</label>
            <div class="col-md-3">
                <?= form_dropdown($grupos,$grupo); ?>
            </div>
            <div class="row col-md-8" id="sub">
                <label class="col-md-2 mt-2">Subgrupo:</label>
                <div class="col-md-5">
                    <?= form_dropdown($subgrupos,$subgrupo); ?>
                </div>
            </div>


        </div>

    </div>

This is where I call them in the controller:

public function index()
{
    $data['titulo'] = 'Catalogo';
    $datos['grupo'] = $this->catalogo_model->grupo();
    $datos2['subgrupo'] = $this->catalogo_model->sub();
    $this->load->view('cabecera', $data);
    $this->load->view('navegacion');
    $this->load->view('Inventario/catalogo',$datos,$datos2);
    $this->load->view('pie',$data);
}

And this is the function of the model, for the two dropdown :

function grupo() {
    $lista = array(''=>'Seleccione grupo');
    foreach($this->db->get('grupo')->result() as $grupo)
        $lista[$grupo->grupo] = $grupo->grupo;
    return $lista;

}

function sub() {
    $lista = array(''=>'Seleccione subgrupo');
    foreach($this->db->get('subgrupo')->result() as $subgrupo)
        $lista[$subgrupo->subgrupo] = $subgrupo->subgrupo;
    return $lista;

}
    
asked by Winston Bustamante 10.10.2018 в 22:15
source

0 answers