[xml+php+as] cant retrieve row $ID in Flash..
Hi.. this is my PHP code
Quote:
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "root";
$pass = "";
$database = "samdb";
$linkID = mysql_connect($host,$user,$pass) or die ("Could not connect to host.");
mysql_select_db($database,$linkID) or die ("Could not find database.");
$query = "SELECT * from songlist WHERE genre='Emo' ORDER BY ID ASC limit 25";
$resultID = mysql_query($query,$linkID) or die ("Data not found");
$xml_output = "<?xml version =\"1.0\"?>\n";
$xml_output = "<songlist>\n";
$count = mysql_num_rows($resultID);
for ($x = 0; $x < $count; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<songlist>\n";
$xml_output .= "\t\t<artist>" . $row['artist'] . "</artist>\n";
$xml_output .= "\t\t<id>" . $row['ID'] . "</id>\n";
$xml_output .= "\t\t<title>" . $row['title'] . "</title>\n";
$xml_output .= "\t</songlist>\n";
}
$xml_output.= "</songlist>";
echo $xml_output;
?>
And if you go to the URL : http://snazzyfm.no-ip.info/shout/songlist_retrieve.php
The results is :
Quote:
onglist>
+
<songlist>
<artist>Starting Line</artist>
<id>416</id>
<title>The Best Of Me (Acoustic)</title>
</songlist>
-
<songlist>
<artist>Brand New</artist>
<id>509</id>
<title>Am I Wrong</title>
</songlist>
-
<songlist>
<artist>Brand New</artist>
<id>510</id>
<title>Moshi Moshi</title>
</songlist>
-
<songlist>
<artist>Further Seems Forever</artist>
<id>566</id>
<title>Monechetti</title>
</songlist>
And in Flash, here's what I did to display all the Artist and Title in sequence.
Quote:
// retrieve songlist
function loadXML2(loaded) {
if (loaded) {
songlist.htmlText = "";
var myXML = xmlData.firstChild.childNodes;
_global.artistA = [];
_global.titleA = [];
for (i=0; i<myXML.length; i++) {
_global.artistA[i] = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
_global.titleA[i] = this.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild.nod eValue;
songlist.htmlText += "<b>"+artistA[i]+"</b> " + titleA[i]+"<br>";
}
}
}
// load songlist
function reloadXML2() {
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML2;
xmlData.load("http://snazzyfm.no-ip.info/shout/songlist_retrieve.php");
}
loop songlist
reloadXML2();
setInterval( reloadXML2, 1000 );
and all is working fine but right now i'd also like to display results of ID in Flash, but this is what i did and it didnt seem to work
Quote:
_global.IDA = []; // added this
_global.IDA[i] = this.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild.nod eValue;
// and this
songlist.htmlText += "<b>"+artistA[i]+"</b> " + titleA[i]+IDA[i]+"<br>";
Or is there something i should know about ID (which is the Primary Key) that cannot be displayed in Flash this way? Please advise someone, I'm stumped!