Link to home
Create AccountLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

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:
		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');
        	
        }

Open in new window


Model Code

public function getEditais($id){
            $sql = "SELECT nome_edital FROM tb_editais_orgao";
            $result = $this->db->query($sql);
            return $result;
            		}

Open in new window


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>

Open in new window


The table has values for the query

User generated image

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
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Eduardo Fuerte

ASKER

Thank you, Marco!

It runs.

Very good assistance.