$value) {
echo "<$key>$value$key>";
}
}
?>
This code snippet should give you a good start. But without the wanted XML structure, it's hard to do better.
However I'm not sure PHP is the right solution for this task. Many tools, like phpmyadmin for example, can output mysql data in XML format.