Flash MySQL XML

//Figure 1.0 Main.fla

var theXML:XML = new XML();
theXML.ignoreWhite = true;

theXML.onLoad = function() {
var nodes = this.firstChild.childNodes;
for(i=0;i<nodes.length;i++) {
theList.addItem(nodes[i].firstChild.nodeValue,i);
}
}

theXML.load(“http://www.yoursite.com/products.php&#8221;);

//Figure 1.1 products.php

<?PHP

$link = mysql_connect(“localhost”,”lee”,”password”);
mysql_select_db(“brimelow_store”);

$query = ‘SELECT * FROM products’;
$results = mysql_query($query);

echo “<?xml version=\”1.0\”?>\n”;
echo “<products>\n”;

while($line = mysql_fetch_assoc($results)) {
echo “<item>” . $line[“product”] . “</item>\n”;
}

echo “</products>\n”;

mysql_close($link);

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s