[flexcoders] Flex via php.

2008-09-03 Thread nash.e2008
hi, my name is JIM, new to the FLEX.

i am wishing if some of you guys can help me out here
and plz help me out here.
i have no idea how I can solve this problem

the question is within communication from flex to php 
and i already succeed receiving value at PHP side although I can not
send value as array from php.
(Im able to get value at php side from Database)
How can I send value from php to flex?

P.S. sorry for my terrible English.

this is a source
 
?php
require_once(DB_Login.php);
$genre_sql = SELECT column FROM table;
$shop_sql = SELECT column FROM table;
$data = new getDBData();
 
$genre_row = $data-get_Data($genre_sql);
$shop_row = $data-get_Data($shop_sql);
 
$return_Data[] = $genre_row;
$return_Data[] = $shop_row;
 
//I am thinking the error is the way to return the value
echo $return_Data[];
 
class getDBData{
 
function getDBData(){
}
 
/**
 * receive the data, and make it array
 * received valueFSQL execute command
 * return valueFarray
 * */
function get_Data($sql){
// MySQL communicating
if (!($rs = mysql_query($sql))) {
die;
}
 
// MySQL viewing record
$init = True;
while ($item = mysql_fetch_array($rs)) {
 
// MySQL init
if ($init) {
 
// MySQL counting # of records
$clct = count($item)  1;
 
// MySQL checking the name of items
reset($item);
for ($i = 0; $i  $clct; $i++) {
$tmp = each($item);  // dummy
$tmp = each($item);
list($mds, $dmy) = $tmp;
}
 
// MySQL command ended
$init = False;
}
 
for ($i = 0; $i  $clct; $i++) {
$array[] = $item[$i];
}
}
return $array;
}
}
 
?
 
source code of receiving the value
private function get_Result(event:Event):void
{
var loader:URLLoader = event.target as URLLoader;
var result:Array = loader.data;

//I have no idea how to receive the value here...
 
}



Re: [flexcoders] Flex via php.

2008-09-03 Thread Michael Schmalle
Hi,

It looks like you want to use AMFPHP and return AMF data serialized.

If you can't use AMF, then you should return your data as xml (create xml
representation of the array you created). Note you don't have to use xml
but, you need some string, not a php array.

In flex, you need to add an event listener to the URLLoader instance and
listen for the complete event, the data will be available in the event
object from the complete event.

Other than that google has a lot about flex/php and the docs show you how to
use the URLLoader and it's dependencies.

Mike


On Wed, Sep 3, 2008 at 9:51 AM, nash.e2008 [EMAIL PROTECTED] wrote:

   hi, my name is JIM, new to the FLEX.

 i am wishing if some of you guys can help me out here
 and plz help me out here.
 i have no idea how I can solve this problem

 the question is within communication from flex to php
 and i already succeed receiving value at PHP side although I can not
 send value as array from php.
 (Im able to get value at php side from Database)
 How can I send value from php to flex?

 P.S. sorry for my terrible English.

 this is a source

 ?php
 require_once(DB_Login.php);
 $genre_sql = SELECT column FROM table;
 $shop_sql = SELECT column FROM table;
 $data = new getDBData();

 $genre_row = $data-get_Data($genre_sql);
 $shop_row = $data-get_Data($shop_sql);

 $return_Data[] = $genre_row;
 $return_Data[] = $shop_row;

 //I am thinking the error is the way to return the value
 echo $return_Data[];

 class getDBData{

 function getDBData(){
 }

 /**
 * receive the data, and make it array
 * received value FSQL execute command
 * return value Farray
 * */
 function get_Data($sql){
 // MySQL communicating
 if (!($rs = mysql_query($sql))) {
 die;
 }

 // MySQL viewing record
 $init = True;
 while ($item = mysql_fetch_array($rs)) {

 // MySQL init
 if ($init) {

 // MySQL counting # of records
 $clct = count($item)  1;

 // MySQL checking the name of items
 reset($item);
 for ($i = 0; $i  $clct; $i++) {
 $tmp = each($item); // dummy
 $tmp = each($item);
 list($mds, $dmy) = $tmp;
 }

 // MySQL command ended
 $init = False;
 }

 for ($i = 0; $i  $clct; $i++) {
 $array[] = $item[$i];
 }
 }
 return $array;
 }
 }

 ?

 source code of receiving the value
 private function get_Result(event:Event):void
 {
 var loader:URLLoader = event.target as URLLoader;
 var result:Array = loader.data;

 //I have no idea how to receive the value here...

 }

  




-- 
Teoti Graphix, LLC
http://www.teotigraphix.com

Teoti Graphix Blog
http://www.blog.teotigraphix.com

You can find more by solving the problem then by 'asking the question'.