rogueblade Posted February 6, 2010 Share Posted February 6, 2010 Hope this is the right board for this...... :-\ Hey guys I'm working on a school assignment in which I have to make a basic CRUD (create, read, update and delete) content management application using the Zend AMF framework in FLEX. Basically I create a mock database and have flex print the data from the database into a data-grid. I need to also have an add form, edit+update feature and delete feature. As of now I have FLEX printing all the database info into my data-grid and my add form works as well as my delete button. My problem is I cannot get the update function/query to work. You know: (UPDATE myTable SET valueName='".$variable."') What happens is I have it programmed so that when you click on any row in the data-grid, the information is printed back into the add form. Here you can change the values and hit the 'update button' (not the add button) to run the update query on the php file. So my mxml looks something like this: <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="{amfcall.getDatabase()}"> <mx:RemoteObject id="amfcall" destination="MyPHPclass" source="MyPHPclass" endpoint="http://localhost/FlexAMFCMSapplication/index.php" showBusyCursor="true" /> //My add form would be here <mx:Button label="Add" id="addbutton" click="senddata()"/> <mx:Button label="Delete" id="delbutton" click="deletedata()"/> <mx:Button label="Update" id="updatebutton" click="updateDatabase()"/> <mx:DataGrid id="dataTbl" dataProvider="{amfcall.getDatabase.lastResult}" editable="false" > <mx:columns> <mx:DataGridColumn headerText="Date" dataField="field_date" /> <mx:DataGridColumn headerText="Time" dataField="field_time" /> <mx:DataGridColumn headerText="Name" dataField="field_name" /> </mx:columns> </mx:DataGrid> <mx:Script> <![CDATA[ public function updateDatabase():void { amfcall.updateDatase(dataTbl.selectedItem.field_id); //I tired adding these: //amfcall.updateDatase(dataTbl.selectedItem.field_name); //amfcall.updateDatase(dataTbl.selectedItem.field_date); //amfcall.updateDatase(dataTbl.selectedItem.field_time); } ]]> </mx:Script> And my PHP like this: class MyPHPclass { public function updateDatabase($id=NULL,$name=NULL,$date=NULL,$time=NULL) { $update = "UPDATE tbl_example SET field_name='".$name."',field_date='".$date."',field_time='".$time."' WHERE field_id=".$id; $updateresult = mysql_query($update); } } So if that makes sense to anyone, what I'm wondering is how do I pass those three values; name, date and time to the PHP so they can be updated. I know my script in the mxml is passing the ID with this line amfcall.updateDatase(dataTbl.selectedItem.field_id); but I don't know if by passing the above it will take all the data relevant to that ID over. The delete function works like this (I'm showing it to show how the php receives the id from the mxml: public function deleteData($id=NULL) { $delete = "DELETE FROM tbl_example WHERE field_id=".$id; $deleteresult = mysql_query($delete); } and the actionscript it in my mxml that is used for the delete function is identical to the one I'm using for the update function: amfcall.deleteData(dataTbl.selectedItem.field_id); So basically I can send the ID over to the PHP but not other values along with it, in this case the date time and name. How can I send over these edited values so the update function actually updates them? I'm assuming my update function is wrong in either the mxml or the php or both. Quote Link to comment Share on other sites More sharing options...
rogueblade Posted February 6, 2010 Author Share Posted February 6, 2010 wow I figured it out. This always happens after taking over half an hour to post my problem, in taking such effort to try make it clear for the forums I figure it out. Mods can delete this haha. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.