Click here to Skip to main content
15,349,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all!

I'm new here, and I have a question.

I can populate a Flex dataGrid with a PHP function through ZendAMF using this MXML in Flex:
<mx:DataGrid x="5.684342E-14" y="0" width="100%" height="100%" editable="false" id="browsegrid" styleName="usermapgrid" dataProvider="{amfcall.getItems.lastResult}" creationComplete="amfcall.getItems()" fontFamily="Verdana" itemClick="itemClickEvent();">

But as soon as I try to populate it with the same return type from a function that requires a variable to be passed, it fails to load the info, but doesn't show an error.

Here is the MXML of the problem:

<mx:DataGrid x="0" y="0" styleName="usermapgrid" height="100%" width="100%" dataProvider="{amfcall.searchItems(searchstring).lastResult}" creationComplete="amfcall.searchItems(searchstring)">

And the corresponding PHP function:

public function searchItems($search){
    $result=mysql_query("SELECT * FROM tbl_items WHERE item_name OR item_tags LIKE '%$search%'");
    return $result;

The PHP is returning properly when I test without Flex.

(I'm using Flex SDK 3.2)

Thanks for any help X| !

1 solution

My knowledge of Flex is limited, so please forgive me, but doesn't PHP send information to Flex via XML, rather than just the result variable?

public function searchItems( $search )
        // Prevent Sql Injection attacks by escaping the string.
        $search = mysql_real_escape_string( $search );

        $result = mysql_query( "SELECT * FROM tbl_items WHERE item_name OR item_tags LIKE '%$search%'" );
	echo '<items>';
	while ( $row = mysql_fetch_array( $result ) )
		echo '<row>';
		echo '	<columnnumber1>' . $row[ 0 ] . '</columnnumber1>';
		echo '	<columnnumber2>' . $row[ 1 ] . '</columnnumber2>';
		echo '</row>';
	echo '</items>';
<mx:DataGrid x="0" y="0" styleName="usermapgrid" height="100%" width="100%" id="datagrid" dataProvider="{amfcall.searchItems(searchstring).lastResult.items.row}" >
        <mx:DataGridColumn headerText="Column 1" dataField="columnnumber1" visible="true"/>
        <mx:DataGridColumn headerText="Column 2" dataField="columnnumber2" visible="true"/>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900