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=”{search.lastResult.search.type}” dataField=”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..

10 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.

    regards,
    kumar.

  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!

    Thanks

  4. kumargandhi Says:

    Can you paste your code sample here .!

    regards,
    kumar.

  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 .= “”;
    while(odbc_fetch_row($queryexe)){
    $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.

    Thanks!

  10. Reading data in to ComboBox from PHP page. (corrections) « flex on blog - by kumar Says:

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

Leave a Reply