Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-01-2006, 07:16 AM   #1
zicemaster
Registered User
 
Join Date: Feb 2006
Posts: 22
Default Help with reversing results... mySQL-AMFPHP-Flash

I have managed to get everything working good and kinda hit a snag with returning data to flash.

Heres my code in flash:
Code:
var conn = NetServices.createGatewayConnection("http://localhost/amfphp/gateway.php");
var myService = conn.getService("shoutBox", this);
function getShouts() {
    myService.getShouts('allShouts');
    myTextField = allShouts;
}
Now heres my problem... I need to be able to return the collumns of my mySQL table to flash, in order of newest to oldest. And so far... I can't get it to work quite right... My current code sends me a VERY long un-orderly array, that I can only seem to see in the NetDebug window.


GetShouts is where I'm having my problem... Any Help? Btw... I'm going to clean it all up once I get it working perfect!
PHP Code:
<?php
class shoutBox{
function 
shoutBox(){
$this->methodTable = array(
"addShout" => array(
//Echoes the passed argument back to Flash (no need to set the return type
"access" => "remote",
"arguments" => array ("userName""userShout"),
"returntype" => "recordSet"
),
"getShouts" => array(
"access" => "remote",
"arguments" => array ("allShouts"),
"returntype" => "Array"
)
);
}

function 
addShout($userName$userShout){
@
mysql_connect('localhost''root''mypass');
@
mysql_select_db('mydb');
$query="INSERT INTO shoutbox (userName,userShout) VALUES('$userName','$userShout');";
mysql_query($query);
mysql_close();
}
function 
getShouts(){
$myArray = array();
@
mysql_connect('localhost''root''mypass');
@
mysql_select_db('mydb');
$sql 'SELECT * FROM shoutbox';
$result mysql_query($sql);
while (
$row mysql_fetch_assoc($result)){
foreach(
$row as $key=>$value){
array_push($myArray$key$value);
}
}
return 
$myArray;
mysql_close();
}
}
?>
zicemaster is offline   Reply With Quote
Old 05-01-2006, 06:42 PM   #2
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

zicemaster,

Why not return all of your results straight to Flash:

PHP Code:
$this->result mysql_query$this->query );
// return the whole table
return $this->result
ActionScript Code:
import mx.remoting.RecordSet; import mx.utils.Iterator; var rs:RecordSet = new RecordSet()// sort the results straight from PHP here instead serviceResult.onResult = function( data:RecordSet ):Void {     rs = data;         var rsIterator:Iterator = rs.getIterator();         while( rsIterator.hasNext() )     {         var currentData:Object = rsIterator.next(); // you could just push them straight into an array     } }

Apologies for not tackling your question directly - but i just thought this might help.

Regards, snapple :]

Last edited by snapple; 05-01-2006 at 06:44 PM.
snapple is offline   Reply With Quote
Reply


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Developing a flash site, Part1: Some thoughts Bloom22 Other Flash General Questions 6 09-29-2006 02:10 AM
Flash -> coldfusion mx7 -> MySQL kalel Flash Remoting 4 04-06-2005 10:36 PM
trying to format records in flash mx coming from mysql olm75 ActionScript 1.0 (and below) 15 02-26-2005 10:00 PM
inserting mysql query results on flash movie? emilioestevezz ActionScript 2.0 0 09-21-2004 03:33 PM
Flash --> PhP / MySQL --> Flash , Data Traffic - yet with a little BUG igx Server-Side Scripting 1 04-21-2003 08:08 PM


All times are GMT. The time now is 01:33 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.