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

Eduardo Fuerte
Eduardo Fuerte used Ask the Experts™
on
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:
img001
The combo is functional but the names (nome_seguradora) doesn't appears.

img002Could you point a workaround on this?

Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Full Stack Developer
Commented:
Share the HTNL you are getting in the browser for the select element.
Eduardo FuerteDeveloper and Analyst
Commented:
Hi

After checking the HTML generated in the browser to attend your request I saw that:

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

Open in new window


Must to be corrected to:
<option value="<?=$each['id_seguradora']?>"><? echo $each['nome_seguradora']?></option>

Open in new window


So everything is fine now...
Eduardo FuerteDeveloper and Analyst

Author

Commented:
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

Eduardo FuerteDeveloper and Analyst

Author

Commented:
Thanks for help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial