PDA

View Full Version : Needing Flash/MySQL Help


SmifWes
02-02-2005, 10:19 PM
I am trying to get the data from my DB and get them into flash. The PHP and .fla file are below. The list.fla file has a layer called "block" in block are movie clips named from 101 to 106. I want to be able to pull each row the DB in to Flash according to the number of each. movie clip. I really need this help badly. Thanks in advanced!

Here's my PHP

<?php

$conn = mysql_connect("localhost", "", "");
mysql_select_db("loft588", $conn);

$sql = "SELECT * FROM units";

$result = mysql_query($sql, $conn);

while ($newArray = mysql_fetch_array($result)) {

$id = $newArray['id'];
$unit = $newArray['unit'];
$floor = $newArray['floor'];
$price = $newArray['price'];
$sqft = $newArray['sqft'];
$fee = $newArray['fee'];
$state = $newArray['state'];

echo "Need to figure out the best way to format this";

}

?>

Here's my Flash...

list2.fla (http://www.mallydangerous.com/list2.fla)

SmifWes
02-03-2005, 02:10 PM
OK, I'm getting closer to what I want. I'm trying to explain this as best I can. Currently, my swf file pulls in the info from my DB. However, I want to assign each of the rows from the DB to a movieclip. How can I do this?

This the PHP...

<?php

$conn = mysql_connect("localhost", "", "");
mysql_select_db("new558", $conn);

$sql = "SELECT * FROM t558";

$result = mysql_query($sql, $conn);

while ($newArray = mysql_fetch_array($result)) {

$id = $newArray['id'];
$unit = $newArray['unit'];
$floor = $newArray['floor'];
$price = $newArray['price'];
$sqft = $newArray['sqft'];
$fee = $newArray['fee'];
$state = $newArray['state'];

echo ("&id=$id&unit=$unit&floor=$floor&price=$price&sqft=$sqft&fee=$fee&state=$state");

}

?>

This is the .fla...

fla file (http://www.mallydangerous.com/you/you.fla)

Mateusz
02-05-2005, 03:21 PM
<?php
$rows = mysql_num_rows($result);
echo("&rows=".$rows);

$c = 0; // c like counter :)

while ($newArray = mysql_fetch_array($result)) {
$id = $newArray['id'];
$unit = $newArray['unit'];
$floor = $newArray['floor'];
$price = $newArray['price'];
$sqft = $newArray['sqft'];
$fee = $newArray['fee'];
$state = $newArray['state'];

echo ("&id".$c."=$id&unit".$c."=$unit&floor".$c."=$floor&price".$c."=$price&sqft".$c."=$sqft&fee".$c."=$fee&state".$c."=$state");

$c++;
}
?>

Then you'll able to check how many rows you got.

In fla file (didn't check it, sorry :) ) you can get variables like this:

for(i = 0; i < yourObjectWithVariables.rows; i++)
{
yourObjectWithVariables["id" + i]; // do something with variable
yourObjectWithVariables["state" + i]; // do something with variable
}