Hi
I need a bit of help with this. I am using some code that I found on the net to make a php script get info from mysql database then return the results in a xml.
[color=#0000ff][color=#000000]The result looks like this [/color][/color][color=red]<[/color][color=red]Record Id>1</Record Id>[/color] but I need the result to look like this [color=red]<Record Record_ID=“1” /> [/color][color=black]Here is the code that I am using:[/color]
<?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 Memory ORDER BY Record_Id ASC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<Memory>
";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= " <Memory>
";
// Escaping illegal characters
$row['Record_Id'] = str_replace("&", "&", $row['Record_Id']);
$row['Record_Id'] = str_replace("<", "<", $row['Record_Id']);
$row['Record_Id'] = str_replace(">", ">", $row['Record_Id']);
$row['Record_Id'] = str_replace("\"", """, $row['Record_Id']);
$xml_output .= " <Record_Id>" . $row['Record_Id'] . "</Record_Id>
";
$xml_output .= " </Memory>
";
}
$xml_output .= "</Memory";
echo $xml_output;
?>
If anyone has any idea.
Thanks Tech-Head