Welcome Guest, Not a member yet? Register   Sign In
DropDown not showing
#1

[eluser]Unknown[/eluser]
Hi,

I am new with PHP and specialy with CodeIgniter, but I have to develop a web interface to do a query in a database and show the results to the user.

Right now I am trying to use the form_dropdown from the form_helper. I searched a bit in this forum and founded something useful for me now, but I am not getting it to work properly. The dropdown list is from a query in the database. But the form is not showing up. Can someone give me a help?

Right below is the View code:
Code:
<?php
$values = $this->db
   ->select('TIPO_ELEMENTO')
   ->get('SYRIP')
   ->result_array();
$options = array();

foreach($values as $value)
{
  $options[$value['TIPO_ELEMENTO']] = $value['TIPO_ELEMENTO'];
}
return $options;  

echo form_dropdown('TesteTipo',$options,null);
#2

[eluser]Mauricio de Abreu Antunes[/eluser]
Post your original code and html output.
Print your array returned from your query.
#3

[eluser]Unknown[/eluser]
Hi,

With the help of a friend, I managed to solve it. Below are the codes:

View:
Code:
<?php

foreach($TipoElemento as $TipoElemento1)
{
$ListaDropTipoElemento[$TipoElemento1] = $TipoElemento1;
}
foreach($Data as $Data1)
{
$ListaDropData[$Data1] = $Data1;
}
foreach($NomeElemento as $NomeElemento1)
{
$ListaDropNomeElemento[$NomeElemento1] = $NomeElemento1;
}

echo form_open('teste');
echo form_dropdown('TesteData',$ListaDropData,null);
echo form_dropdown('TesteTipoElemento',$ListaDropTipoElemento,null);
echo form_dropdown('TesteNomeElemento',$ListaDropNomeElemento,null);
echo form_close();

HTML Output:

Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;

&lt;/head&gt;
&lt;body&gt;
<h1>Welcome to CodeIgniter!</h1>

<div id="container">
&lt;form action="localhost/index.php/teste" method="post" accept-charset="utf-8"&gt;&lt;select name="TesteData">
<option value="2012-02-17">2012-02-17</option>
<option value="2012-02-24">2012-02-24</option>
</select><select name="TesteTipoElemento">
<option value="HLR">HLR</option>
<option value="MSC">MSC</option>
</select><select name="TesteNomeElemento">
<option value="HRJO02">HRJO02</option>
<option value="HRJO01">HRJO01</option>

<option value="HBHE01">HBHE01</option>
<option value="HRJO03">HRJO03</option>
<option value="HSPO02">HSPO02</option>
<option value="HSNE03">HSNE03</option>
<option value="HSPO03">HSPO03</option>
<option value="HSPO04">HSPO04</option>
<option value="HSNE02">HSNE02</option>
<option value="HSPO01">HSPO01</option>
<option value="HSNE01">HSNE01</option>

</select>&lt;/form&gt;&lt;/div>
<div id="container">
</div>
<div id="container">
<p.footer>Rodape</p.footer>
</div>
&lt;/body&gt;
&lt;/html&gt;

Thanks!!




Theme © iAndrew 2016 - Forum software by © MyBB