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

asked on

How to make an array to accept the first value to be presented in a combobox?

Hi Experts

Having this code

 function get_orgao($idprograma = 0) 
  {
	// Select your records
    	$this->db->select('idorgao, nome');
        $this->db->from('tb_orgao');
        $this->db->order_by('nome');
        $this->db->where('idprograma', $idprograma);
		
	   // Get the results 
	   $results = $this->db->get()->result_array();

	   // Add the SELECT item to the start of the array
    	array_unshift($results, array('id' => '0', 'name' => 'SELECT'));

	   return $results;
    }

Open in new window


What must be needed to make the combo presents  
- SELECT -
as the 1st line of the combo instead of undefined

User generated image
Thanks in advance!
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Hi,
what does the PHP function generate and how is that incorporated to the page?
Could you post the resulting HTML source (not the PHP source)?
How is that dropdown filled? By HTML source or via JavaScript?

Thanks.
Rainer
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland 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
Avatar of Eduardo Fuerte

ASKER

Perfect!

Thank you very much.