I am working on this application and want to insert items into the database. I have an id, item and amount that I want to insert.
I have generated a form with Flash Builder and I am able to insert data into the text box, click the select button and a new row is being made with an id but the input that I insert for item and amount are not being shown.
php file
php fileCode:public function saveData($basketc) { if ($basketc == NULL) return NULL; //logMe($author); //connect to the database. $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD); mysql_select_db(DATABASE_NAME); if ($basketc->id > 0) { //save changes $query = "UPDATE basket SET item='".$basketc->item."', amount='".$basketc->amount."' WHERE id". $basketc->id; } else { //add new record $query = "INSERT INTO basket (item, amount) VALUES ('".$basketc->item."', '".$basketc->amount."')"; } $result = mysql_query($query); return NULL; }
<?php
class BasketVO {
var $id;
var $item;
var $amount;
}
?>
mxml file
Any help or advice would be much appreciated.Code:<?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:packageservice="services.packageservice.*" xmlns:valueObjects="valueObjects.*" xmlns:author="services.author.*" xmlns:basket="services.basket.*" title="Add Basket Item"> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; </fx:Style> <fx:Script> <![CDATA[ import com.adobe.serializers.utility.TypeUtility; import mx.events.FlexEvent; protected function saveaddbasketitem(event:MouseEvent):void { // TODO Auto-generated method stub navigator.pushView(views.BasketView); } protected function form_creationCompleteHandler(event:FlexEvent):void { saveDataResult.token = basket.saveData(basket); } protected function button_clickHandler(event:MouseEvent):void { basketVO.amount = amountTextInput.text; basketVO.item = itemTextInput.text; } ]]> </fx:Script> <fx:Declarations> <valueObjects:BasketVO id="basketVO"/> <basket:Basket id="basket"/> <s:CallResponder id="saveDataResult" result="basketVO = saveDataResult.lastResult as BasketVO"/> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <s:Form id="form" creationComplete="form_creationCompleteHandler(event)" defaultButton="{button}"> <s:FormItem label="Amount"> <s:TextInput id="amountTextInput" width="426" text="{basketVO.amount}"/> </s:FormItem> <s:FormItem label="Item"> <s:TextInput id="itemTextInput" width="429" text="{basketVO.item}"/> </s:FormItem> <s:Button id="button" label="Submit" click="button_clickHandler(event)"/> </s:Form> </s:View>


Reply With Quote



Bookmarks