# Xml Mysql

**URL:** <https://forum.kirupa.com/t/xml-mysql/126130>\
**Category:** Uncategorized\
**Created:** [October 20, 2004, 6:18pm UTC](https://forum.kirupa.com/t/xml-mysql/126130 "2004-10-20T18:18:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tech\_Head](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@Tech\_Head](https://forum.kirupa.com/u/Tech_Head)\
**Post date:** [October 20, 2004, 6:18pm UTC](https://forum.kirupa.com/t/xml-mysql/126130/1 "2004-10-20T18:18:38Z")

</div>

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]

```auto
 
<?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(">", "&gt;", $row['Record_Id']); 
		$row['Record_Id'] = str_replace("\"", "&quot;", $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
