How do I add array values that are numbers when loaded dynamically via sql?
Example script doesn’t calculate. Instead it just adds as though the elements of ycor array are string based. So ycor[0] = 2 and ycor[1] = 3 added equals 23 not 5. Of course these elements are being dynamically set via mysql db that generates a xml table. I’ve left out file locations and passwords for obvious reasons. Why are the elements being treated as strings?
var theXML:XML = new XML();
theXML.ignoreWhite = true;
theXML.onLoad = function(success:Boolean) {
if (success) {
main = [];
caption = [];
areaName = [];
areaType = [];
hyplnk = [];
ycor = [];
var nodes = this.firstChild;
var total = nodes.childNodes.length;
for(i=0;i<total;i++) {
main* = nodes.childNodes*.attributes.main;
caption* = nodes.childNodes*.attributes.caption;
areaName* = nodes.childNodes*.attributes.areaName;
areaType* = nodes.childNodes*.attributes.areaType;
hyplnk* = nodes.childNodes*.attributes.hyplnk;
ycor* = nodes.childNodes*.attributes.ycor;
}
images()
}
else {
statusArea.text = "Could not load SQL database" + '
'
}
}
func images(){
statusArea.text = ycor[0] + ycor[1] //<--- This doesn't give me 5 it gives 23
}
theXML.load("GetInfo.php");
<?PHP
$link = mysql_connect("location","user","pass");
mysql_select_db("db");
$query = 'SELECT * FROM table';
$results = mysql_query($query);
echo "<?xml version=\"1.0\"?>
";
echo "<menu>
";
while($line = mysql_fetch_assoc($results)) {
echo "<subitem main='". $line["main"] . "' caption='". $line["caption"] . "' hyplnk='". $line["hyplnk"] . "' ycor='". $line["ycor"] . "'></subitem>
";
//echo "<subitem>" . $line["main"] . "</subitem>
";
}
echo "</menu>
";
mysql_close($link);
?>