Read Data from Database into DataGrid Control: PHP backend

As we know that flex app reads data in the form of XML, so we have to send data from PHP page in the form of XML.So that it can be embed into the datagrid control.

So the PHP page looks like this below, which generates XML lookslike data.

echo “<product>”;

echo “<items>”;
echo “<name1>”Kumar”</name>”;
echo “<name2>”Gandhi”</link>”;
echo “</items>”;

echo “</product>”;

Now in the flex app use HTTPService to get the data,like below.

<mx:HTTPService id=”productlist” url=”product_.php” useProxy=”false” showBusyCursor=”true” />

Now in the datagrid control use the dataprovider property to mention the httpservice id and in the datagridcolumn use the property datafield to the required field in to the column.

<mx:DataGrid x=”10″ y=”39″ height=”200″ id=”datagrid” dataProvider=”{productlist.lastResult.product.items}” >
<mx:columns>
<mx:DataGridColumn headerText=”FirstName” dataField=”name1″ visible=”true”/>
<mx:DataGridColumn headerText=”Last Name” dataField=”name2″ visible=”true”/>
</mx:columns>
</mx:DataGrid>

4 Responses to “Read Data from Database into DataGrid Control: PHP backend”

  1. Martin Tomaszczyk Says:

    thanks for this :)

  2. sakthipsm Says:

    thanks for this

  3. crusader Says:

    please explain the content of dataprovider what is lastResult doing. Thank you .

  4. jindal Says:

    works for me

Leave a Reply