spangle1187 Posted February 2, 2011 Share Posted February 2, 2011 I will start with what I have and what little I know (and please do point out anything that you think is incorrect or poorly structured): The overall goal is that upon page load my php webpage will fire a sql_query to a MySQL db from which the php will generate an xml document within the php page using xmlDom. The xml data will then be read by ActionScript 3 to enable Flash to draw a visual representation of what is in the db. I have a php webpage that is linked to a MySQL db, using an xmlDom I have created an xml document that sits inside the php page. I have used xmlDom over simpleXML as the xmlDom library and construct looks more powerful and I want to create xml not just read the nodes and handle the data. There is one element that I can’t seem to shake and this is causing me to think that I have constructed the xmlDom wrong and that is it only works if I echo the xml to the screen. This is the code for the php webpage: <?php include("php/dbconnect.php"); //connects to the database //sql_query $table_id = 'booking'; $query = "SELECT * FROM $table_id WHERE (booking.bookingDate = curDate()) AND roomID = 1 ORDER BY startTime"; $room1 = mysql_query($query); //create a new DOM document $doc = new DOMDocument('1.0'); //create root element $root = $doc->createElement('root'); $root = $doc->appendChild($root); //process one row at at time while($row = mysql_fetch_assoc($room1)){ //add node for each row $occ = $doc->createElement($table_id); $occ = $root->appendChild($occ); //add achild for each field foreach ($row as $fieldname => $fieldvalue){ $child = $doc->createElement($fieldname); $child = $occ->appendChild($child); $value = $doc->createTextNode($fieldvalue); $value = $child->appendChild($value); } } $xml_string = $doc->saveXML(); //print $xml_string; mysql_free_result($room1); ?> I also have a Flash document to which I have added an urlloader to read xml documents and hopefully read the xml generated by the php page. This is the code for the Flash file. var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML(); xmlLoader.addEventListener(Event.COMPLETE, LoadXML); xmlLoader.load(new URLRequest("booking.xml")); function LoadXML(e:Event):void { xmlData = new XML(e.target.data); trace(xmlData); dynamictxt.text = xmlData; } The problem I am having now is getting them to work together! The urlloader file in Flash works fine with a test xml document but the xml generated in the php page does not have a name and I do not require it to print to the screen? How can I marry these two together? I have not tried to give the xml document a name but if I remove the echo or print the xml file is not generated. Thank you for reading my long post and even more so if you have solution or a nudge! Link to comment https://forums.phpfreaks.com/topic/226472-the-end-is-neari-think/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.