Good evening!
I need to return the value of a table in codeigniter but it is acknowledging the error below:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: name
Filename: paneladmin / categories.php
Line Number: 7
But my function in the model is correct, it follows below:
public function get_bynome($nome=NULL){
if($nome != NULL):
$this->db->where('nome', $nome);
$this->db->limit(1);
return $this->db->get('categorias');
else:
return FALSE;
endif;
}
And the call in the view looks like this:
echo '<div class="small-12 columns">';
echo breadcrumb();
$query = $this->categorias->get_bynome($nome)->row();
erros_validacao();
get_msg('msgok');
echo form_open('categorias/cadastrar', array('class'=>'custom'));
echo form_fieldset('Cadastrar nova categoria');
echo form_label('Nome');
echo '<div class="row">';
echo '<div class="small-5 columns">';
echo form_input(array('name'=>'nome'), set_value('nome'), 'autofocus');
echo '</div>';
echo '</div>';
echo form_label('Categoria Pai');
echo '<div class="row">';
echo '<div class="small-5 columns">';
echo form_dropdown('Categoria Pai', $query->nome, 'Selecione uma opção');
echo '</div>';
echo '</div>';
public function cadastrar(){
//esta_logado();
$data['query'] = $this->categorias->get_bynome($nome)->row();
$this->load->view("categorias", $data);
It seems that the variable is not declared something like this, I did not find the error.