Eduardo Fuerte
asked on
Could you clear what must be done for Codeigniter scope a variable correctly?
Hi Experts!
I'm facing a problem related with variable scope in Codeigniter
Controller code:
Model Code
View code
The table has values for the query
The variable $resultadoIca is not visible in the view code....
Could you point what could be necessary to that?
(if any other directive is necessary)
Thanks in advance!
I'm facing a problem related with variable scope in Codeigniter
Controller code:
public function compraspublicas($ano=false,$mes=false){
$buscatesteira['buscatesteira'] = $this->home_model->getTesteira(3);
$this->load->vars($buscatesteira);
$data2['title'] = "ICA - COMPRAS PÚBLICAS";
$this->load->view('template_head',$data2);
$this->load->view('home/barrasp/barra.html');
$this->load->view('home/nome_codeagro');
$this->load->view('home/banner_setores');
$this->load->view('ica/menu.php');
//Provisório
$quantidade = 10;
//
$resultadoIca['resultadoPublicacoes'] = $this->icahome_model->
getEditais($quantidade);
//$paginacao['paginacao'] = $this->pagination->create_links();
$this->load->vars($resultadoIca);
$this->load->view('ica/compraspublicas.php');
$this->load->view('home/projetos');
}
Model Code
public function getEditais($id){
$sql = "SELECT nome_edital FROM tb_editais_orgao";
$result = $this->db->query($sql);
return $result;
}
View code
<div class="tab" id="tab1" style="display: block;">
<p>Conteudo da tab1 - Qualquer HTML válido pode preencher</p>
<?php
if (empty($resultadoIca))
{
echo 'No momento, não encontram-se cadastrados editais. ';
}
else
{
echo 'Existem editais. ';
}
// This causes errors
foreach ($resultadoIca as $resultadoIca)
{
echo 'Edital';
}
?>
</div>
The table has values for the query
The variable $resultadoIca is not visible in the view code....
Could you point what could be necessary to that?
(if any other directive is necessary)
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
It runs.
Very good assistance.