# Variables in Dynamic Text Boxes

**URL:** <https://forum.kirupa.com/t/variables-in-dynamic-text-boxes/316280>\
**Category:** flash\
**Created:** [November 17, 2010, 5:22pm UTC](https://forum.kirupa.com/t/variables-in-dynamic-text-boxes/316280 "2010-11-17T17:22:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vickyh](https://avatars.discourse-cdn.com/v4/letter/v/8baadc/32.png) [@vickyh](https://forum.kirupa.com/u/vickyh)\
**Post date:** [November 17, 2010, 5:22pm UTC](https://forum.kirupa.com/t/variables-in-dynamic-text-boxes/316280/1 "2010-11-17T17:22:49Z")

</div>

Hi Guys!

Newbie here! Hoping you can help me out though - I must say Kirupa has been SO helpful in my journey learning AS3 and getting my projects off the ground, so I must say thank you to everyone first of all. 😃

So, here is my conundrum:

I have a PHP file which is correctly pulling records from a SQL database. What I need to do is place each new record into a new text box.

I understand that I need to assign a variable to each record as it comes through the PHP file and that Flash needs to know which variable to assign to which text box. So, in that respect I have added a counter to the PHP script (it is performing correctly)

Essentially I was hoping you guys could assist me with the ActionScript on how to pull the correct variables. Below is the code I have, PHP first:

\<?PHP

$link = mysql\_connect(“localhost:3306”, “root”, “”);  
mysql\_select\_db(“test”);

$result = mysql\_query(‘SELECT Brand, Style, Sample FROM stock’);

$count=0;

while($row=mysql\_fetch\_array($result)){

```
echo "$row[Brand]";
echo "$row[Style]

```

";  
echo “$row[Sample]”;

$count++;

}

**And the the ActionScript:**

var myLoader:URLLoader = new URLLoader();  
//the data will come as URL-encoded variables  
myLoader.dataFormat = URLLoaderDataFormat.TEXT;  
//Load using an URLRequest, even being local  
myLoader.load(new URLRequest(“[http://localhost/autumnleaf/new6.php](http://localhost/autumnleaf/new6.php)”));  
//onLoad handler listener  
myLoader.addEventListener(Event.COMPLETE, onDataLoad);  
//Error handling  
myLoader.addEventListener(IOErrorEvent.IO\_ERROR, onIOError);  
myLoader.addEventListener(SecurityErrorEvent.SECURITY\_ERROR, onSecurityError);  
//Could be an error or just a message  
myLoader.addEventListener(HTTPStatusEvent.HTTP\_STATUS, onHTTPStatus);  
//add a listener for the complete event  
function onDataLoad(evt:Event){  
//trace(evt.target.data);  
list1.text = unescape(evt.target.data.)  
}  
//error callbacks  
function onIOError(evt:IOErrorEvent){  
trace("IOError: "+evt.text)  
}  
function onHTTPStatus(evt:HTTPStatusEvent){  
trace("HTTPStatus: "+evt.status)  
}  
function onSecurityError(evt:SecurityErrorEvent){  
trace("SecurityError: "+evt.text)  
}

At the moment using the above script Flash is putting all the SQL data into one text box. I have previously tried to alter the evt.target.data to correctly assign the variables, but this has failed.

Any help is most appreciated!

Vicky
