spangle1187 Posted February 1, 2011 Share Posted February 1, 2011 I have managed to retrieve an sql query and through php create an xml document, my next aim is to get this code into actionscript so that I can use the data in Flash. One problem I am experiencing is that in creating the xml document the data within xml nodes are echoed to the screen, I do not want them to be echoed to the screen just picked up by actionscript. Is there a way to created an xml document using php that does not print to the screen? <?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 = $doc->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(); echo $xml_string; mysql_free_result($room1); ?> Quote Link to comment https://forums.phpfreaks.com/topic/226331-creating-an-xml-document-that-does-not-print-to-the-screen/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 1, 2011 Share Posted February 1, 2011 You output an xml document to whatever client requested the page/document. If you are simply browsing to the page, you should expect to see the xml being rendered in the browser. Quote Link to comment https://forums.phpfreaks.com/topic/226331-creating-an-xml-document-that-does-not-print-to-the-screen/#findComment-1168265 Share on other sites More sharing options...
spangle1187 Posted February 1, 2011 Author Share Posted February 1, 2011 Do you have any examples of this as all that I can find echo to the screen rather than outputing to a different client? Quote Link to comment https://forums.phpfreaks.com/topic/226331-creating-an-xml-document-that-does-not-print-to-the-screen/#findComment-1168270 Share on other sites More sharing options...
PFMaBiSmAd Posted February 1, 2011 Share Posted February 1, 2011 When a client makes a HTTP request to a server for a page, that page is output/echoed back to the client. Ref: http://en.wikipedia.org/wiki/HTTP Quote Link to comment https://forums.phpfreaks.com/topic/226331-creating-an-xml-document-that-does-not-print-to-the-screen/#findComment-1168272 Share on other sites More sharing options...
spangle1187 Posted February 1, 2011 Author Share Posted February 1, 2011 My misunderstanding, the client in this case is loading a php page that upon loading runs an sql_query to a MySQL DB that then displays a visual using Flash representation of this query. The client does not request to see the xml page and that is why I am trying not to echo the data to the screen. I was advised that ActionScript and Flash can read xml very well so that is why I am creating the xml page. Quote Link to comment https://forums.phpfreaks.com/topic/226331-creating-an-xml-document-that-does-not-print-to-the-screen/#findComment-1168280 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.