Código:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" creationComplete="send_data()"> <mx:Script> <![CDATA[ private function send_data():void { userRequest.send(); } ]]> </mx:Script> <mx:Button label="Submit" click="send_data()"/> <mx:AdvancedDataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.lastResult.catalogo.producto}"> <mx:columns> <mx:AdvancedDataGridColumn headerText="nombre" dataField="nombre"/> <mx:AdvancedDataGridColumn headerText="imagen" dataField="'images/catalogo/enfriadores/'+direccion"/> </mx:columns> </mx:AdvancedDataGrid> <mx:Label x="301" y="88" id="selectednombre" text="{dgUserRequest.selectedItem.nombre}"/> <mx:Image x="301" y="128" id="selectedimage" source="images/catalogo/enfriadores/{dgUserRequest.selectedItem.direccion}"/> <mx:HTTPService id="userRequest" url="http://localhost/pruebaFlex-debug/php/bbdd.php" useProxy="false" method="POST"> <mx:request xmlns=""> <subcategoria>{3}</subcategoria> </mx:request> </mx:HTTPService> <mx:HorizontalList y="550" dataProvider="{userRequest.lastResult.catalogo.producto}" horizontalCenter="0" width="80%" height="170"> </mx:HorizontalList> </mx:Application>
Código PHP:
<?php
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "root" );
define( "DATABASE_NAME", "frivall" );
//connect to the database.
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
mysql_select_db( DATABASE_NAME );
// Quote variable to make safe
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
//return a list of all the users
$Query = "SELECT * FROM catalogo WHERE subcategoria = ".$_POST["subcategoria"];
$Result = mysql_query( $Query );
$Return = "<catalogo>";
while ($User = mysql_fetch_object($Result))
{
$Return .= "<producto><nombre>".$User->nombre."</nombre><direccion>".$User->imagen."</direccion></producto>";
}
$Return .= "</catalogo>";
mysql_free_result( $Result );
print ($Return)
?>
Un saludo y gracias.