Reading data in to ComboBox from PHP page.

First the PHP page looks like this:

echo “<search>”;
echo “<type name=’kumar’ />” ;
echo “<type name=’gandhi’ />” ;
echo “</search>”;

here we have to send data from PHP page in this format.Then to take data in to ComboBox we have to use a HTTPService and dataProvider Property of the ComboBox control.

<mx:HttpService id=”search” useproxy=”false” url=”first.php”/>

<mx:ComboBox id=”searchbox” dataProvider=”{}” labelField=”name” />

Here in the dataField property specifies which attribute value you wanted from the list.

Here name is the attribute of the <type> tag in PHP and that data i wanted it in the ComboBox list.thats it its simple and small try it..

Leave any comments for suggestions..

Correction are made to this post Plz refer the Below link::

Reading data in to ComboBox from PHP page.Β (corrections)


28 Responses to Reading data in to ComboBox from PHP page.

  1. Jerry says:

    it doesn’t work!

  2. kumargandhi says:

    Hi Jerry,

    It should work , plz check the code once again , or can you paste your code sample here so that i can have a glance and make some suggestions.


  3. Jerry says:

    I get an error that dataField does not exist. The thing is I am using Flex 3 so i am not sure I can use your example!


  4. kumargandhi says:

    Can you paste your code sample here .!


  5. John says:

    Not working for me either.
    Flex 3.0:

    Php output, saved as .xml file for testing:

  6. John says:

    Kumar said:
    It works fine and should work , r u getting any error message , r u sending the Httpservice , the code is correct.Plz have a look .

    I don’t get an error message, the file is in the same directory, I don’t know what you mean by “sending the Httpservice”. The combobox just doesn’t get populated.

    When you say “It works fine,”, whose code are you referring to, mine or yours?

    Mine does not work.

  7. Tiger says:

    Hi guys,
    i tried this example. It worked. Only think i did was made few changes to the php page.
    below is the php code to display states in XML format:
    $sql = “select distinct state from schedule”;

    $queryexe = odbc_do($connectionstring, $sql);
    $cnt = 0;
    $Return .= “”;
    $state = odbc_result($queryexe, 1);
    $Return .= “”.$state.””;
    $Return .= “”;
    echo “$Return”;

    MXML file:

  8. Tiger says:

    MXML file:

  9. John says:

    Well, I figured it out.

    The application tag needs a creationComplete=”search.send()”

    Maybe you should specify this in your little blog post so newbies can actually use your example.


  10. […] post missed one line as it was pointed out in the comment , the line is to send the HttpService you are […]

  11. suramya says:


  12. kumargandhi says:

    your welcome. And there’s another post relating to this with correction plz refer that.,and the link for that is above your comment.


  13. Koeno says:

    This doesn’t work form me,
    flex3 tells me that dataField isn’t a property of Combobox

  14. kumargandhi says:

    There are some mistakes in this post and I have corrected them.
    Plz do refer the below link.

    And link is provided in this post also.Just added. πŸ™‚ .. For any queries message.


  15. I think you should point out the another side of the topic too… Hats Off to the discussion.

  16. Pradip Jadhav says:


    I want to show users with with their id as a value and user name as a text in combo box. I have created one file that returns data in xml format but i am not able to assign value to every option in combo box.

    Will u plz send me a simple example for this πŸ™‚

    Thanx in advance

    Pradip Jadhav

  17. Pradip Jadhav says:

    Hello Kumar,

    I want to call One Mxml File From Another File Just like if i am on login.html and after successful login i redirects to welcome.html. Just like this i want to call welcome.mxml after successful login.

    So is there any way to call other mxml file from one file….?

    Thanx in advance…….:)

    Pradip Jadhav

    • kumargandhi says:


      Hence Flex is not document driven App we have views, the UI is divided into different views and these are views are made with different Components like TitleWindow,Canvas,Panel, CustomComponents , and these are loaded in to the App.So for your kind we can use States and Transitions in Flex they are very useful in this kind,just explore them you will find good example on that NP.


  18. Pradip Jadhav says:

    Thanx a lot Kumar…………. πŸ™‚

    One more problem i am using datagrid in which i am showing list of users. In my datagrid there is last column having text as a Edit User.

    Now on clicking Edit User i want to call one function having parameter as as userId of current record.

    I am not getting how to pass UserId of current record to function… 😦

    Will u please help me………?

    Thanx in advance

    Pradip Jadhav

    • kumargandhi says:


      the current selected record can be accessed like , dg.selectedItem , if dataField of that column is USERID then it would look like, dg.selectedItem.USERID , it contains the selected userid as per your example.Note here dg is the id of the DataGrid.


  19. Dgspfg says:

    I couldn’t make it work… here are my codes

    I hope you can help me

    • kumargandhi says:


      I checked your code and use this as dataProvider in to your ComboBox.

      rest everything is fine and now it will work.


  20. sk says:

    sum1 plz help i wnt the codin to calculate options/combobox(vat calculator) dnt be suprised stil learnin

  21. I’ve been trying to explain the exact thing to my pals but I think it’s better if I just email them the link to this site instead! Thanks for writing such an insightful post.Nice one.

  22. murali says:

    first i convey my wishes ur blog is very very good
    i need one help
    i want insert item xml
    i give xml format

    i want additem at below this element

  23. Hukamchand says:

    I have try an example to click on one combobox & display dat related that combobx display in another combobox.. in php
    fo eg.. if i select one state in one combobox then display related district for that state in another state…..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: