Enum - How to Get String in DropdownList

Talk about any other operations you need to implement: additions, updates etc.

Moderator: alexandrleonenko

tazmanyak
Newbie
Newbie
Posts: 4
Joined: Oct 21st, '14, 20:51

Enum - How to Get String in DropdownList

Postby tazmanyak » Oct 21st, '14, 21:16

Hi,

I'm trying to achive inserting values selected from dropdownlist but all the time its inserting integer values. I know that the format is like ;
$fill_from_array = array("0"=>"No", "1"=>"Yes") so perhaps, sql query inserts 0 and 1 to the sql table. But what i want to achieve is getting strings shown in dropdownlist.
I'm new in apPHP DataGrid. I'm able to post datagrid and edits etc correctly. I have no problem but I want to get the string value instead integer. If you can help me to do so, I'll be very pleased. Thanks in advance.

administrator
Site Admin
Site Admin
Posts: 6004
Joined: Jan 7th, '09, 23:18
Contact:

Re: Enum - How to Get String in DropdownList

Postby administrator » Oct 22nd, '14, 18:21

What do you mean "to achive"?

Use following: $fill_from_array = array("no"=>"No", "yes"=>"Yes")

tazmanyak
Newbie
Newbie
Posts: 4
Joined: Oct 21st, '14, 20:51

Re: Enum - How to Get String in DropdownList

Postby tazmanyak » Oct 22nd, '14, 20:20

I know but I'm filling array from sql when it is done the array looks like array( "0" => "Yes", "1"=>"No"). So how can i convert this to what you suggest ?

tazmanyak
Newbie
Newbie
Posts: 4
Joined: Oct 21st, '14, 20:51

Re: Enum - How to Get String in DropdownList

Postby tazmanyak » Oct 22nd, '14, 20:38

Ok. I solved the problem. I just combined array with itself. Like ;

$list = array_combine($username_combo, array_values($username_combo));

Initially ==> array( 0 => username, .... , ) and after combination ==> ( username => username, .... .. )

Thanks.


Return to “Additional operations implementation”