FLASH得到MYSQL数据

Flex 间接得到Mysql数据库数据。

 

AS3

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
				layout="absolute"
				backgroundGradientColors="[#FFFFFF, #FFFFFF]"
				creationComplete="test.send()">
	<mx:Script>
		<![CDATA[
			[Bindable]
			private var Url:String='http://127.0.0.1/Tiaop/COM/app.PhoneInfo.php?id=2';
		]]>
	</mx:Script>

	<mx:HTTPService id="test"
					url="{Url}">

	</mx:HTTPService>
	<mx:DataGrid x="60"
				 y="250"
				 width="950"
				 dataProvider="{test.lastResult.TIAOP}"/>
</mx:Application>

别人写的xml生成类


<?php

class xml {
        var $xml;
        function xml($array,$encoding='utf8') {
                $this->xml='<?xml version="1.0" encoding="'.$encoding.'" ?><?pageview_candidate ?>';
                $this->xml.=$this->_xml($array);
                
        }
        function getXml() {
                return $this->xml;
        }
        function _xml($array) {
                foreach($array as $key=>$val) {
                        is_numeric($key)&&$key="item id=\"$key\"";
                        $xml.="<$key>";
                        $xml.=is_array($val)?$this->_xml($val):$val;
                        list($key,)=explode(' ',$key);
                        $xml.="</$key>";
                }
                return $xml;
        }
}
?>

xml

<?php

$id=$_GET['id'];

include ("../CORE/core.php");

//连接MYSQL
$mysql = Mysql::getInstance ();
$mysql->config ($MysqlInfo);

//查询
$phone = $mysql
->select('phone')
->where('id='.$id.'')
->limit(1)
->done();

// 生成
$arr=array('TIAOP'=>
     array('ID'=>$phone[0][id],'PRICE'=>$phone[0][price],'NAME'=>$phone[0][name],'INFORMATION'=>$phone[0][information],'IMAGE'=>$phone[0][image]));

$ax=new xml($arr);
echo $ax->getXML();


?>

posted @ 2010-11-08 09:29  noevil  阅读(1158)  评论(0编辑  收藏  举报