I have a MySQL database with the following fields: ID, fname, user, contact, telephone, email, status, comment. I need help with the PHP code to get the data into xml. For the flash interface I am using: XML Connector, Dataset, Data grid. I am unsure how to pass the updates made by users back to the database. Could anyone offer any assistance. Many thanks
Attached a snippet to demonstrate the use of PHP to echo a XML-file to Flash. If you want to send variables to PHP, use the LoadVars class. If you use POST (default for LoadVars) your variables are accessed in PHP by using: $_POST['example']; Build a UPDATE or INSERT query with your variables and save it to the database. // (part of the) php-file // $result is a SELECT query on the database <?php echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<datapacket>'; while($row = mysql_fetch_array($result)){ $line = '<row Menu="'.$row[subtitle].'" Sub="'.$row[headline].'" Text="'.$row[body].'" Picture="'.$row[image].'" Page="'.$row[category_name].'" Title="'.$row[category_title].'" />'; echo $line; } echo '</datapacket>'; ?> // xml returned to flash (row with attributes in this example) <?xml version="1.0" encoding="UTF-8"?> <datapacket> <row Menu="Information" Sub="Our Company" Text="We have an incredible company with nice people and you should be one of our clients and pay us a lot of money." Picture="building.jpg" Page="Company" /> </datapacket>
Don't see what you're looking for? Try a search.
|