# Displaying Multiple rows of data from database

**URL:** <https://forum.kirupa.com/t/displaying-multiple-rows-of-data-from-database/48299>\
**Category:** programming\
**Created:** [April 12, 2004, 10:31am UTC](https://forum.kirupa.com/t/displaying-multiple-rows-of-data-from-database/48299 "2004-04-12T10:31:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zor](https://avatars.discourse-cdn.com/v4/letter/z/848f3c/32.png) [@Zor](https://forum.kirupa.com/u/Zor)\
**Post date:** [April 12, 2004, 10:31am UTC](https://forum.kirupa.com/t/displaying-multiple-rows-of-data-from-database/48299/1 "2004-04-12T10:31:20Z")

</div>

Hello,

Firstly, I’d just like to say that I’ve searched the tutorials and the forums for an answer but I can’t find one. I’ve tried to use code from the tutorial from here [http://www.kirupa.com/web/sqlrecords\_php.htm](http://www.kirupa.com/web/sqlrecords_php.htm) but I can’t get the code to work.

I’m having problems with sending multiple rows of data from a database as variables from mysql/php to flash. I can read individual values, but I can’t grab multiple ones and then send them as variables to Flash.  
The database is a simple News one with 6 fields; **id** ,\*\* name\*\*, **date** , **time** , \*\*descrip \*\*and **venue**. At the moment there are 6 sample entries with values in the above.

I would like the php to take the first row/entry and print out the variables into Flash. The first lot of variables for the first row will be “ **name1** ”, “ **date1** ”, “ **time1** ”…etc. WHen that is finished, the code then gets the second row and prints them out “ **name2** ”, **date2** …etc  
However, when I test it in Flash, all that happens is I get the first couple of values from the first row out and everything else is ‘undefined’ i.e, Flash can’t find it. A strange thing is that when I try to get “descrip1”, it actually returns “name2=blahblah” , where name 2 is the right one.

Heres the code:

```php
<?php
$conn = mysql_connect("localhost", " *****" , "*****");
$select = mysql_select_db("cuba", $conn);
$result = mysql_query("SELECT * FROM news ORDER BY id");
 
$x = 1;
while($result_ar = mysql_fetch_assoc($result)){
 
				 $phpname = $result_ar["name"];
		$phpdate = $result_ar["date"];
		$phptime = $result_ar["time"];
		$phpvenue = $result_ar["venue"];
		$phpdescrip = $result_ar["descrip"];
 
print "name".$x."=".$phpname."&date".$x."=".$phpdate."&time".$x."=".$phptime.
"&venue".$x."=".$phpvenue."&descrip".$x."=".$phpdescrip;
 
$x+=1;
}
?>

```

So at the end in Flash I would like to recieve the variables, name1, date1, time1, venue1, descrip1… then name2, date2, venue2, descrip2 … all the way up to the last entry. I’m also pretty certain that my actionscript is ok, its just a fe typical LoadVars lines with a trace command to test it.

Any help is really appreciated!

Thanks…

Zor
