Could you point a way to form a view's combo based on Codeigniter's results?

Hi Experts

Could you point a way to form a view's combo based on Codeigniter's results?

Accordingly to:

Controller's code:
public function index() {

	// SELECT/DROPDOWN - Seguradora
	$fk_seguradora = $this->cliente_corporativo_model->new_get(array('query' => 'select * from system_seguradora'));
	$dropdown[0] = 'Selecione ...';
	foreach ($fk_seguradora as $key => $value)
		$dropdown[$value->id_seguradora] = $value->nome_seguradora;

	$this->data['fk_seguradora'] = form_dropdown('fk_seguradora', $dropdown, '', 'id="id_seguradora"');
	unset($dropdown);
	
	...

Open in new window



View's code:
The values are actually "hard coded"
  <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>
			<span class="select">
				<select id="fk_seguradora" name="fk_seguradora">
					<option value="" selected="selected">...Cliente Corporativo...</option>
					<option value="1">Ace</option>
					<option value="2">Zurich</option>
					<option value="3">Banco Safra</option>
					<option value="4">SANTANDER</option>
					....
				</select>
			</span>
		</div>
	</div>
</div>

Open in new window


I tryed to do this way:
<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>
			<span class="select">
				<select id="fk_seguradora" name="fk_seguradora">
				
                                  // A for-each at this point makes sense?? - I guess there is a better option.
				   <option value="<?php $id_seguradora?>"><?$fk_seguradora?></option>
 
						
				</select>
			</span>
			</label>
		</div>
	</div>
</div>

Open in new window


Thanks in advance!
Eduardo FuerteDeveloper and AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Hey Eduardo,

You seem to already be creating the drop down in your Controller code by using the form_dropdown() method, so you would just need to echo that out in your view:

<?php echo $fk_seguradora ?>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eduardo FuerteDeveloper and AnalystAuthor Commented:
Hi @Chris

You are perfectly right.

I'm the meanwhile I did this way:

 <div class="row">
                <div class="col-xs-12 mb15">                           
                    <!--label for="fk_seguradora" class="field-label text-muted mb10">Cliente Corporativo</label-->
                    <!--span class="input-group-addon "-->
                            <i class="fa fa-search c-gray"></i>
                    <!--/span-->
                    <label for="fk_seguradora" class="validar field select">
                        <?php echo $fk_seguradora; ?>
                        <i class="arrow double"></i>
                    </label>
                </div>
            </div>

Open in new window


Just a problem in correctly positionate the icon.
img001
Chris StanyonWebDevCommented:
That's more likely to be a CSS issues rather than a CodeIgniter one.
Eduardo FuerteDeveloper and AnalystAuthor Commented:
I'm going to ask another question on this particular subject, since it has derivated from the initial question.

Thanks for help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.