I was reading this
http://www.kirupa.com/web/mysql_xml_php.htm
tutorial and there is a thing i didnt understand, wich is this single line inside the loop:
[SIZE=2][FONT=Courier New][COLOR=#0000bb]$row [/COLOR] [COLOR=#007700]= [/COLOR][COLOR=#0000bb] mysql_fetch_assoc[/COLOR]COLOR=#007700;
Why it uses the var $resultID ? Since what the loops change is the var $x
that should be the var to take each line and make it an array, isnt it?
this is the complete code
[/COLOR][/FONT][/SIZE]
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "root";
$pass = "";
$database = "test";
$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 blog ORDER BY date DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<entries>
";
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(">", ">", $row['text']);
$row['text'] = str_replace("\"", """, $row['text']);
$xml_output .= " <text>" . $row['text'] . "</text>
";
$xml_output .= " </entry>
";
}
$xml_output .= "</entries>";
echo $xml_output;
?>