Adobe Flex

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentAdobe Flex

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old March 21st, 2013, 07:39 AM
dimiorla dimiorla is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 dimiorla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 32 sec
Reputation Power: 0
Array to amfphp.

Hi Everyone,
I would like to insert all the rows from a list in one go to mysql.
Does anyone have an example/ tutorial?
This is my code
EDIT:
According to Charles the content is an array with four objects and every one two strings, but i get Invalid argument supplied for foreach().
does for foreach() expect something else than strings?
Code:
	<fx:Script>
	<![CDATA[
		import mx.rpc.events.ResultEvent;
		import mx.collections.ArrayCollection;
            
            [Bindable]
		public var srclistCA:ArrayCollection = new ArrayCollection([
            {Name:'Bob', LastName: 'Jones' },  
            {Name:'Jane', LastName: 'Smith' },
            {Name:'Doug', LastName: 'Johnson' },   
            {Name:'John', LastName: 'Jackson'}]);
	
            [Bindable]
		public var DataArray:Array = srclistCA.source;
			
		public function send():void {  
		Service.insertData(DataArray.source);  
		}
		]]>
	</fx:Script>
	<fx:Declarations>
 	<s:RemoteObject id="Service" source="test" destination="amfphp" requestTimeout="10"
		showBusyCursor="true" endpoint="http://192.168.0.102/pos/gateway.php">
			<s:method name="insertData"/>
	</s:RemoteObject>
	</fx:Declarations>
	<s:List id="srclist" x="0" y="0" width="226" height="759" dataProvider="{srclistCA}"/>
	<s:Button x="473" y="10" label="send" click="send()"/>

PHP Code:
function insertData($DataArray) {
foreach(
$array as $DataArray)
      
mysql_query("INSERT INTO adress (Name, LastName) VALUES (
          '"
.$array ['Name']."',
          '"
.$array ['LastName']."')");
   } 

Any help is appreciated
Thanks in advance Dimitris.

Last edited by dimiorla : March 22nd, 2013 at 02:15 PM.

Reply With Quote
  #2  
Old March 22nd, 2013, 02:32 PM
dimiorla dimiorla is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 dimiorla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 32 sec
Reputation Power: 0
THE SOLUTION:
PHP Code:
function insertData($DataArray) {
     for (
$i 0$i count($DataArray); $i++)
           {
           
$name$DataArray[$i][name];
           
$lastname$DataArray[$i][lastname];
           
mysql_query("INSERT INTO adress (Name, LastName) 
           VALUES ('
$name','$lastname')");
           }


Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentAdobe Flex > Array to amfphp.


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap