I have a Mysql database and I am trying to import multiple records with multiple columns into Flash AS3 using PHP. My problem is I am able to make it work with a single column and multiple records but for multiple columns I am not being able to format it correctly. What i wish to have is an array(of records) of associative arrays(of columns) i.e. I want to be able to partition the output from php based on '|' and store it in a flash array and then be able to access name,id for each of them (see below the code).
the php part ->
<?php
......//other code
$result = mysql_query($sql);
$output = "success=$db&myArrayForFlash=";
//error check
...
//form the return string
while($myRow = mysql_fetch_assoc($result)){
$arrayElement = "&name=".$myRow['name'];
$arrayElement = $arrayElement."&id=".$myRow['id'];
$output = $output."$arrayElement" . "|";
}
}
echo($output);
?>
the flash part->
function completeHandler(e:Event):void
{
if(e.target.data.success=="1"){
var myArray:String = e.target.data.myArrayForFlash;
var myCol:String = myArray[0]['id'];
this.var= e.target.data.myArrayForFlash.split("|");;
//do something else
}
else
{
Alert.show("Query failed. \n");
}
}
the problem is I get an array of names,id but the myArrayForFlash is empty.
Is there any way to get past this?
I am a total newbie to flash/php (less than 3 weeks of experience) so some complete reply will be highly appreciated. Thanks a lot!