Generate XML from mysql table using PHP

Its very easy generating xml from php. I have created the following script to achieve this. The same script I used to create simple query analyser using flex.

function getXML($sql=”Default Query”)
$result = mysql_query($sql,$conn);
echo “<records>”;
foreach($row as $key => $value)
echo $columns;
echo “</records>”;
getXML(“SELECT * FROM tableName”);


This simple function is very useful in different manner. You can used it when you want to write ajax application, Flex Application.


5 Responses to Generate XML from mysql table using PHP

  1. A great start to what I want to build – a Flex front end for wordpress for a blog that is actually more of a product gallery but using the category / post editing features of WordPress as it’s CMS. Just have to figure out the post = picture piece and pull it together. Thanks for sharing!

  2. Baalu says:

    thanks sir. its very use full for me ..

    Thanks once again..

    |) (\ (\ |_ |_|

  3. Varun says:

    Thanks a lot!!!

    I needed it for my project.

  4. Charlie says:

    Thankyou so much, i really needed this, I didn’t think about content-type headers, so my mp3 player wouldn’t work for ages, thanks!

  5. raghavendra says:

    Hi , i have data like in mysql say column name and value but i need this data to be displayed in this formate…

    could you help in on this please

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: