Extract data from SQL and display as XMl using PHP

Hi all,

I have used the below code:

<?php

header("Content-type: text/xml");

$host = "****";
$user = "*****";
$pass = "*****";
$database = "******";

$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");

$query = "SELECT * FROM `counter_history` LIMIT 0 , 30";
$resultID = mysql_query($query, $linkID) or die("Data not found.");

$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<startdate>
";

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
    $row = mysql_fetch_assoc($resultID);
    $xml_output .= "	<entry>
";
    $xml_output .= "		<date>" . $row['date'] . "</date>
";
        // Escaping illegal characters
        $row['text'] = str_replace("&", "&", $row['text']);
        $row['text'] = str_replace("<", "<", $row['text']);
        $row['text'] = str_replace(">", "&gt;", $row['text']);
        $row['text'] = str_replace("\"", "&quot;", $row['text']);
    $xml_output .= "		<text>" . $row['text'] . "</text>
";
    $xml_output .= "	</entry>
";
}

$xml_output .= "</startdate>";

echo $xml_output;

?> 

My problem is, it geterates the XML files on screen, but does not extract any data from my database.

Any ideas? I have little knowledge so the simpler the better :slight_smile:

regards

Chris