Am attempting to write a php script that exports a database and prints the contents as XMl. So for i've this

<?php
require('connect.php');

$query = mysql_query("SELECT * FROM blog_comments");
$database="MyWebsite";
$table = "blog_comments";
echo mysql_error();


echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";

echo "<$database>";
$i=0;
while($row=mysql_fetch_assoc($query))
{
    echo "<$table>";
            while ($i < mysql_num_fields($query))
            {
                $meta = mysql_fetch_field($query);
                echo "<".$meta->name.">".$row['$meta->name']."</".$meta->name."><br/>";
                $i++;
            }
            $i=0;
    echo "</$table>";
}

echo "</$database>";


?>

And my output is

<?xml version="1.0" encoding="utf-8" ?>
<MyWebsite>
<blog_comments>
    <></>
    <></>
    <></>
    <></>
    <></>
    <></>
    <></>
    <></>
</blog_comments>
<blog_comments>
    <></><></><></><></><></><></><></><></>
</blog_comments>
<blog_comments> 
    <></><></><></><></><></><></><></><></>
</blog_comments>
<blog_comments>
    <></><></><></><></><></><></><></><></>
</blog_comments>
<blog_comments>
    <></><></><></><></><></><></><></><></>
</blog_comments>
<blog_comments>
    <></><></><></><></><></><></><></><></>
</blog_comments>
<blog_comments>
    <></><></><></><></><></><></><></><></>
</blog_comments>
<MyWebsite>

The amount of things are correct but for whatever reason i'm not obtaining the values printed. Am carrying this out because my websites host does not allow remote database connections and I have to connect with a database from the java application. So i wish to call a php page from the java application also it would respond with xml that contains my data and that i then parse this XML and employ the appropriate data

I want help how to make this happen in order to attain the above goal.. thanks Thanks.

I am not positive, however i think mysql_fetch_assoc is essentially "burning" your query result, which for the similar query, you cannot refer to it as first. However, you don't have to grab all of this area information if all that's necessary may be the title, only use:

echo "<{$table}>";
foreach($row as $key => $val){
    echo "<{$key}>{$val}</{$key}>";
}
echo "</{$table}>";