# MySql, loop and Flash

**URL:** <https://forum.kirupa.com/t/mysql-loop-and-flash/229216>\
**Category:** programming\
**Created:** [June 14, 2007, 10:17pm UTC](https://forum.kirupa.com/t/mysql-loop-and-flash/229216 "2007-06-14T22:17:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RubenFlash](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@RubenFlash](https://forum.kirupa.com/u/RubenFlash)\
**Post date:** [June 14, 2007, 10:17pm UTC](https://forum.kirupa.com/t/mysql-loop-and-flash/229216/1 "2007-06-14T22:17:52Z")

</div>

Hi! 🍺

I was wondering whats the best approach to do a query to a mysql database, and getting all the results from a table into Flash. I was thinking something like this:

```php

var a:Number = 1;
var total:Number = 3;
var loads = new LoadVars();
var sends = new LoadVars();

sends.sendAndLoad('go.php?rand='+getTimer()+random(9999), loads, 'POST');

loads.onLoad = function(Success:Boolean){
    if(Success){
        //attaches some Movieclip
        something = this.variable;
        if(a<total){
            a++;
            sends.sendAndLoad('go.php?rand='+getTimer()+random(9999), loads, 'POST');
        }
    }
}

```

The go.php does a query to the database. So this does a sort of a loop, and, each time it gets the variables from the go.php, it sends again the request to another query. But I’m worried about the efficiency of this approach, because it does a query for every movie I want to attach.  
So, is it better to do a single query in php and get all the results to an array and then send it to Flash? But how can I do that? I think that flash doesnt “reads” array sent from php, or does it?

Anyway, any help you could provide, I would be grateful. Thanks!
