Hi,
I'm trying to use a php script to fetch data from mysql and present is as a xml file.
The xml file is to be read by flash.
i'm using php script as down below.
When i access this script through my browser, the output is perfectly alright.
Trying to access it in Flash... nothing happens.
On the flash stage i'm using an XML connector, a Dataset and a datagrid.
the action script included is xml_conn.trigger();
this works fine with a plain XML file (xml_conn points to mydata.xml) , but i can not get it working for a php generated xml file (xml_conn point to the php file).
i suspect it has something to do with xml_conn.trigger()? or the XML data generated with the php dom function is incompatible with the format required by flash?
Any sugestions please?
Thanks
PAtrick
$table_id = 'some_table';
$query = "SELECT * FROM $table_id";
$dbresult = mysql_query($query, $dbconnect);
// create a new XML document
$doc = new DomDocument('1.0');
// create root node
$root = $doc->createElement('root');
$root = $doc->appendChild($root);
// process one row at a time
while($row = mysql_fetch_assoc($dbresult)) {
// add node for each row
$occ = $doc->createElement($table_id);
$occ = $root->appendChild($occ);
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
$value = $doc->createTextNode($fieldvalue);
$value = $child->appendChild($value);
} // foreach
} // while
// get completed xml document
$xml_string = $doc->saveXML();
echo $xml_string;
?>
I'm trying to use a php script to fetch data from mysql and present is as a xml file.
The xml file is to be read by flash.
i'm using php script as down below.
When i access this script through my browser, the output is perfectly alright.
Trying to access it in Flash... nothing happens.
On the flash stage i'm using an XML connector, a Dataset and a datagrid.
the action script included is xml_conn.trigger();
this works fine with a plain XML file (xml_conn points to mydata.xml) , but i can not get it working for a php generated xml file (xml_conn point to the php file).
i suspect it has something to do with xml_conn.trigger()? or the XML data generated with the php dom function is incompatible with the format required by flash?
Any sugestions please?
Thanks
PAtrick
$table_id = 'some_table';
$query = "SELECT * FROM $table_id";
$dbresult = mysql_query($query, $dbconnect);
// create a new XML document
$doc = new DomDocument('1.0');
// create root node
$root = $doc->createElement('root');
$root = $doc->appendChild($root);
// process one row at a time
while($row = mysql_fetch_assoc($dbresult)) {
// add node for each row
$occ = $doc->createElement($table_id);
$occ = $root->appendChild($occ);
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
$value = $doc->createTextNode($fieldvalue);
$value = $child->appendChild($value);
} // foreach
} // while
// get completed xml document
$xml_string = $doc->saveXML();
echo $xml_string;
?>