# Help with reversing results... mySQL-AMFPHP-Flash

**URL:** <https://forum.kirupa.com/t/help-with-reversing-results-mysql-amfphp-flash/187640>\
**Category:** programming\
**Created:** [May 1, 2006, 7:07am UTC](https://forum.kirupa.com/t/help-with-reversing-results-mysql-amfphp-flash/187640 "2006-05-01T07:07:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zicemaster](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@zicemaster](https://forum.kirupa.com/u/zicemaster)\
**Post date:** [May 1, 2006, 7:07am UTC](https://forum.kirupa.com/t/help-with-reversing-results-mysql-amfphp-flash/187640/1 "2006-05-01T07:07:36Z")

</div>

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

Heres my code in flash:

```auto

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

<?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();
      }
}
?>

```

---

<div class="post-metadata">

**Author:** ![bwh2](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bwh2](https://forum.kirupa.com/u/bwh2)\
**Post date:** [May 1, 2006, 7:14am UTC](https://forum.kirupa.com/t/help-with-reversing-results-mysql-amfphp-flash/187640/2 "2006-05-01T07:14:14Z")

</div>

you need to ORDER BY your date variable in your getShouts query.

---

<div class="post-metadata">

**Author:** ![zicemaster](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@zicemaster](https://forum.kirupa.com/u/zicemaster)\
**Post date:** [May 1, 2006, 7:43am UTC](https://forum.kirupa.com/t/help-with-reversing-results-mysql-amfphp-flash/187640/3 "2006-05-01T07:43:19Z")

</div>

> [@bwh2](#):
>
> you need to ORDER BY your date variable in your getShouts query.

Thanks for the heads up! I found this, and it works: $sql = ‘SELECT \* FROM shoutbox ORDER BY id DESC’;

But I still have problems returning it to flash… Augh! Anyone good with AMFPHP around here? Omg… This is embarassing… It’s returning to flash on the NetDebug, yet I can’t seem to figure out where it is returning TO.

```auto

DebugId: "0"
EventType: "Result"
MovieUrl: "file:///C|/Program Files/xampp/htdocs/amfphp/services/SQLtesting.swf"
Protocol: "http"
Source: "Client"
Time: 1146469494796
Date (object #1)
....."Mon May 1 00:44:54 GMT-0700 2006"
Result (object #2)
.....[0]: "id"
.....[1]: "39"
.....[10]: "userShout"
.....[11]: "SQL TESTING!"
.....[12]: "id"
.....[13]: "37"
.....[14]: "userName"
.....[15]: "Test Name"
.....[16]: "userShout"
.....[17]: "SQL TESTING!"
.....[2]: "userName"
.....[3]: "Test Name"
.....[4]: "userShout"
.....[5]: "SQL TESTING!"
.....[6]: "id"
.....[7]: "38"
.....[8]: "userName"
.....[9]: "Test Name"

```
