# Loading database stuff through PHP/Flash

**URL:** <https://forum.kirupa.com/t/loading-database-stuff-through-php-flash/79052>\
**Category:** flash\
**Created:** [February 10, 2005, 2:47pm UTC](https://forum.kirupa.com/t/loading-database-stuff-through-php-flash/79052 "2005-02-10T14:47:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mprzybylski](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mprzybylski/32/613_2.png) [@mprzybylski](https://forum.kirupa.com/u/mprzybylski)\
**Post date:** [February 10, 2005, 2:47pm UTC](https://forum.kirupa.com/t/loading-database-stuff-through-php-flash/79052/1 "2005-02-10T14:47:26Z")

</div>

ok, i have a database with two tables. one table holds the following:

table 1 name: lots  
columns: lot\_id, number, description, status\_id  
table 2 name: status  
columns: status\_id, name, description

i have a php script that goes as follows (i’m ignoring the description fields for now):

```php
<?php

// database connection variables
$server = "localhost";
$username = " ********";
$password = " ******";
$database = " ***********";

// database connection statement
$connect = mysql_connect($server, $username, $password);
mysql_select_db($database, $connect);

// get values from the database
$query = "SELECT * FROM lots";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);

// loop through database to get the values
for ($i = 0; $i < $num_results; $i++) {
	$row = mysql_fetch_assoc($result);
	$id .= $row['lot_id'] . "
";
	$lot .= $row['number'] . "
";
	$lotStatus .= $row['status_id'] . "
";
}

// output the variables so that flash can read them
$output = "" ;
$output .= "id=" . $id . "&" ;
$output .= "lot=" . $lot . "&" ;
$output .= "lotStatus=" . $lotStatus ;

// echo the final output lines
echo $output;

?>

```

now i’m not 100% sure this script is correct, so if anyone sees problems in it, please do let me know. i know that it needs some additions to pull the linking table (status) to display the status\_id, but i have no clue how to write that as im not familiar with php, i just took this script from a user on this forum (i apologize for forgetting your name) and edited it.

anyway, i want to be able to pull out all those fields and load them up in flash so i can use them in the scripts over there. i have a grasp on the LoadVars(); a bit but not sure how to pull all this out and if its correct so that i can use it in flash. the fields im most worried about using is the number field in the lots table and the status\_id (in both i guess since its a linking table).

any help would be VERY greatly appreciated. thanks in advance.
