Link to home
Start Free TrialLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

asked on

Could you point how to correctly present an already obtained array from CodeIgniter's model in the View?

Hi Experts


Could you point how to correctly present an array already obtained from CodeIgniter's model in the View?

Controller's code:
$this->data['fk_seguradora_f'] = $this->seguradora_model->get_seguradoras();

Open in new window


Model's Code:
function get_seguradoras( ) 
{ 
	$fk_seguradora_f = array();

	$query=$this->db->query("SELECT id_seguradora, nome_seguradora FROM system_seguradora");
	$fk_seguradora_f = $query->result_array();

	return $fk_seguradora_f;
}

Open in new window


View's code
<div class="row">
	<div class="col-xs-12 mb15">
		<div class="input-group">
			<span class="input-group-addon ">
				<i class="fa fa-search c-gray"></i>
			</span>
			<!--EF Jan/2017 - Campo de filtro dinamicamente formado --->
			 <span class="select">
				 <select id="fk_seguradora" name="fk_seguradora">
						<?php
						
                                               var_dump('testeyyy'); // just to locate the code easily.
						var_dump($fk_seguradora_f);
						die;
						
						
						foreach($fk_seguradora_f as $each)
						{
						?>
							<option value="<?=$each['id_seguradora']?>"><? echo $each['nome_seguradora']?></option>
						<?php
						}
						?>
				</select>
			  </span>
		</div>
	</div>
</div>

Open in new window


Debbuging, the array is correctly obtained in the view:
User generated image
The combo is functional but the names (nome_seguradora) doesn't appears.

User generated imageCould you point a workaround on this?

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of Mukesh Yadav
Mukesh Yadav
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eduardo Fuerte

ASKER

I inverted:

Correct

<option value="<?=$each['id_seguradora']?>"> <?=$each['nome_seguradora']?></option>

Open in new window



Incorrect:
<option value="<?=$each['id_seguradora']?>"><? echo $each['nome_seguradora']?></option>

Open in new window

Thanks for help.