/*
[Bindable]
public var rows1:ArrayCollection=new ArrayCollection([
['Google', [{Projectname:"1", Client:0},
{Projectname:"2", Client:1},
{Projectname:"3", Client:2},
{Projectname:"4", Client:3}]
],
['Yahoo', [{Projectname:"1", Client:4},
{Projectname:"2", Client:1},
{Projectname:"3", Client:2},
{Projectname:"4", Client:1}]
],
]);
*/
我有一個表,我需要得到這種格式的輸出回到Flex,我不能夠太......任何人都可以指出我在哪裏錯了我的PHP它不會在上面輸出這個輸出。獲取陣列集合中的輸出
PHP代碼:
public function getAllProjects()
{
$findings=array();
$sql="SELECT id,projectname FROM project";
$result=mysql_query($sql);
if(!$result)
{
throw new Exception("QUERY FAILED.\n\n".mysql_error());
}
while(list($id,$projectname)=mysql_fetch_row($result))
{
$dataArray=array();
$sql="SELECT state AS state FROM project WHERE id= '$id'";
$result2=mysql_query($sql);
if(!$result2)
{
throw new Exception("QUERY FAILED.\n\n".mysql_error());
}
while($row=mysql_fetch_array($result2))
{
$dataArray[]=$row;
}
$findings[]=array($projectname,$dataArray);
}//while
return $findings;
}
我知道,PHP沒有ArrayCollection中。從PHP
$rows=array(
array('ssss1232',array(array("projectname"=>"1", "clientname"=>0),
array("projectname"=>"2", "clientname"=>1),
array("projectname"=>"3", "clientname"=>3),
array("projectname"=>"4", "clientname"=>3))
),
array('sssss',array(array("projectname"=>"1", "clientname"=>0),
array("projectname"=>"2", "clientname"=>1),
array("projectname"=>"3", "clientname"=>2),
array("projectname"=>"4", "clientname"=>1))
),
);
所需的格式看起來像json給我。那是你要做的嗎?此外,你的代碼格式是有點嚇人;)垂直空間是好的。 – 2009-11-25 18:24:22