FLEX端:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="ro.getOperation('getProductList').send()">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<s:RemoteObject id="ro"
destination="amfphp"
source="ProductServices"
showBusyCursor="true"
endpoint="http://localhost/amfphp/gateway.php"
>
<s:method name="getProductList" fault="getProductList_faultHandler(event)"
result="getProductList_resultHandler(event)" />
<s:method name="ProductInfoToInsert" result="getProInsert_handler(event);"/>
</s:RemoteObject>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ArrayUtil;
import tuto.pro;
[Bindable]
public var dp:ArrayCollection=new ArrayCollection;
//刷新功能
private function getProductList_resultHandler(event:ResultEvent):void
{
dp=new ArrayCollection(ArrayUtil.toArray(event.result));
}
//amfphp请求失败时调用方法
private function getProductList_faultHandler(event:FaultEvent):void
{
Alert.show("失败了",event.fault.message);
}
//添加数据
private function getProInsert_handler(event:ResultEvent):void
{
var pp:pro=new pro();
pp.id=proid.text;
pp.proname=proname.text;
pp.price=price.text;
pp.num=num.text;
pp.total=total.text;
pp.description=descript.text;
ro.productInfoToInsert(pp);
}
]]>
</fx:Script>
<s:Label x="128" y="81" width="41" height="22" text="单号:"/>
<s:TextInput id="proid" x="186" y="77"/>
<s:Label x="364" y="77" width="38" height="21" text="单价:"/>
<s:TextInput id="proname" x="410" y="77"/>
<s:Label x="582" y="77" width="56" height="22" text="单价:"/>
<s:TextInput id="price" x="646" y="77"/>
<s:Label x="128" y="131" width="41" height="18" text="数量:"/>
<s:TextInput id="num" x="186" y="131"/>
<s:Label x="364" y="131" width="41" height="22" text="总价:"/>
<s:TextInput id="total" x="413" y="131"/>
<s:Label x="585" y="131" width="53" height="22" text="备注:"/>
<s:TextInput id="descript" x="646" y="131"/>
<s:DataGrid id="Ide" x="186" y="224" width="551" height="292" dataProvider="{dp}" requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="id" headerText="编号"></s:GridColumn>
<s:GridColumn dataField="proname" headerText="商品名称"></s:GridColumn>
<s:GridColumn dataField="price" headerText="单价"></s:GridColumn>
<s:GridColumn dataField="num" headerText="数量"></s:GridColumn>
<s:GridColumn dataField="total" headerText="总价"></s:GridColumn>
<s:GridColumn dataField="description" headerText="描述"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:Button x="312" y="183" label="添加" click="ro.getOperation('productInfoToInsert').send()"/>
<s:Button x="482" y="183" label="刷新" click="ro.getOperation('getProductList').send()"/></s:Application>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="ro.getOperation('getProductList').send()">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<s:RemoteObject id="ro"
destination="amfphp"
source="ProductServices"
showBusyCursor="true"
endpoint="http://localhost/amfphp/gateway.php"
>
<s:method name="getProductList" fault="getProductList_faultHandler(event)"
result="getProductList_resultHandler(event)" />
<s:method name="ProductInfoToInsert" result="getProInsert_handler(event);"/>
</s:RemoteObject>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ArrayUtil;
import tuto.pro;
[Bindable]
public var dp:ArrayCollection=new ArrayCollection;
//刷新功能
private function getProductList_resultHandler(event:ResultEvent):void
{
dp=new ArrayCollection(ArrayUtil.toArray(event.result));
}
//amfphp请求失败时调用方法
private function getProductList_faultHandler(event:FaultEvent):void
{
Alert.show("失败了",event.fault.message);
}
//添加数据
private function getProInsert_handler(event:ResultEvent):void
{
var pp:pro=new pro();
pp.id=proid.text;
pp.proname=proname.text;
pp.price=price.text;
pp.num=num.text;
pp.total=total.text;
pp.description=descript.text;
ro.productInfoToInsert(pp);
}
]]>
</fx:Script>
<s:Label x="128" y="81" width="41" height="22" text="单号:"/>
<s:TextInput id="proid" x="186" y="77"/>
<s:Label x="364" y="77" width="38" height="21" text="单价:"/>
<s:TextInput id="proname" x="410" y="77"/>
<s:Label x="582" y="77" width="56" height="22" text="单价:"/>
<s:TextInput id="price" x="646" y="77"/>
<s:Label x="128" y="131" width="41" height="18" text="数量:"/>
<s:TextInput id="num" x="186" y="131"/>
<s:Label x="364" y="131" width="41" height="22" text="总价:"/>
<s:TextInput id="total" x="413" y="131"/>
<s:Label x="585" y="131" width="53" height="22" text="备注:"/>
<s:TextInput id="descript" x="646" y="131"/>
<s:DataGrid id="Ide" x="186" y="224" width="551" height="292" dataProvider="{dp}" requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="id" headerText="编号"></s:GridColumn>
<s:GridColumn dataField="proname" headerText="商品名称"></s:GridColumn>
<s:GridColumn dataField="price" headerText="单价"></s:GridColumn>
<s:GridColumn dataField="num" headerText="数量"></s:GridColumn>
<s:GridColumn dataField="total" headerText="总价"></s:GridColumn>
<s:GridColumn dataField="description" headerText="描述"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:Button x="312" y="183" label="添加" click="ro.getOperation('productInfoToInsert').send()"/>
<s:Button x="482" y="183" label="刷新" click="ro.getOperation('getProductList').send()"/></s:Application>
解决方案 »
- wordpress幻灯片插件问题
- apache无法解析php的问题
- flash如何调用xml的数据,数据是图片和超链接
- 模板是gbk编码,php程序是utf-8,数据库是gbk.从程序里直接传输到数据库会乱码,请问如何解决,
- 关于dedecms 中[field:arcurl/]标签链接地址是怎么生成的....
- 问个 关联表单 的问题,达人们进来帮忙,小弟解决不了
- 在搜索结果中如何显示带关键字的那段字节
- 元旦快乐,新年快乐。散分
- 新手问题?望各位指点!!谢谢
- php curl抓取百度搜索页面,无法翻页
- 关于php触发器跟处理器的一些小问题,谢谢!
- 想要实现手机动态注册和发送动态码的登录功能,仿美团的..
require_once "./pro.php";
class ProductServices{
/**
*query product list
*/
function getProductList(){
$link=@mysql_connect("localhost", "root", "123") or die("Could not connect");
mysql_select_db("info",$link);
mysql_query("set names utf8",$link);
$result = mysql_query("SELECT * FROM pro",$link);
$array=array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
array_push($array,$row);
}
mysql_free_result($result);
mysql_close($link);
return $array;
}
function ProductInfoToInsert()
{
$link=@mysql_connect("localhost","root","123");
mysql_select_db("info",$link);
mysql_query("set names utf8",$link);
$sql = "insert into pro(id,proname,price,num,total,description) values ('" . $Id . "','" . $Proname . "','" . $Price . "','" . $Num . "','" . $Total . "','" . $Description . "')";
$result=mysql_query($sql);
if($result)
{
echo ("Sucess");
}
else
{
echo ("fault");
}
mysql_close($link);
}
}
?>
-- version 2.10.2
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2016 年 09 月 22 日 13:35
-- 服务器版本: 5.0.45
-- PHP 版本: 5.2.3SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";--
-- 数据库: `info`
-- -- ----------------------------------------------------------
-- 表的结构 `pro`
-- CREATE TABLE `pro` (
`id` int(11) NOT NULL,
`proname` varchar(200) NOT NULL,
`price` float(10,2) NOT NULL,
`num` int(15) NOT NULL,
`total` float(15,2) NOT NULL,
`description` varchar(400) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;--
-- 导出表中的数据 `pro`
-- INSERT INTO `pro` VALUES (1609030001, '苹果', 4.50, 3, 13.50, '8点40分购买');
INSERT INTO `pro` VALUES (1609030052, '桔子', 2.50, 6, 15.00, '9点20分购买');
INSERT INTO `pro` VALUES (1609170002, '葡萄', 1.00, 3, 3.00, '8点50分购买');
INSERT INTO `pro` VALUES (1609181212, '火龙果', 15.00, 3, 45.00, '9');
INSERT INTO `pro` VALUES (1609181217, '火龙果', 15.00, 3, 45.00, '九点四十分购买');
INSERT INTO `pro` VALUES (1609180062, '7', 1.00, 3, 3.00, '于8点购买');
INSERT INTO `pro` VALUES (1609180245, '草莓', 1.00, 3, 3.00, '8');
INSERT INTO `pro` VALUES (1609200001, '葡萄', 4.50, 6, 27.00, '李三卖于9点25分');
INSERT INTO `pro` VALUES (0, '', 0.00, 0, 0.00, '');
PHP映射文件
class pro
{
var $Id;
var $Proname;
var $Price;
var $Num;
var $Total;
var $Description;
//explicit actionscript package
var $_explicitType = "tuto.pro";
}
?>
/ ActionScript file
package tuto
{
[Remoteclass (alias="tuto.pro")]
[Bindable]
public class pro
{
public var id:String;
public var proname:String;
public var price:String;
public var num:String;
public var total:String;
public var description:String;
public function pro()
{
}
}}
现在是能插入数据库,但只有数字,中文显示不了,只能插入一次,刷新不了数据,这就有点无语了
插入的信息:INSERT INTO `pro` VALUES (0, '', 0.00, 0, 0.00, '');
在测试网页上写入的,好疼呀,都快半个月了,求大神帮忙呀