DB output XML with PHP

ok i can get the data from the DB with php and display it as XML.
My problem is more on the formating side i am currently displaying xml like this:


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<content>
<websites>
<project>WEBSITE01</project> 
</websites>
<websites>
<project>WEBSITE02</project> 
</websites>
</content>

but i need it to out put like this, and include a count and get the id:


<?xml version="1.0" encoding="ISO-8859-1\?>
<content>
 
<websites count="6">
 
<project id="1">WEBISTE 01</project>
<project id="3">WEBISTE 02</project>
<project id="2">WEBISTE 03</project>
<project id="42">WEBISTE 04</project>
<project id="6">WEBISTE 05</project>
<project id="5">WEBISTE 06</project>
 
</websites>
 
<print count="4">
 
<project id="22">PRINT01</project>
<project id="46">PRINT02</project>
<project id="18">PRINT03</project>
<project id="10">PRINT04 (REBRANDED)</project>
 
</print>
 
<motion count="2">
 
<project id="13">MOTION01 (:30 TVC)</project>
<project id="38">MOTION02 (3:00 TRAILER)</project>
 
</motion>
</content>

So how would i get it to look like that.
Below is my php code that outputs the xml.


<?php 
 
header("Content-type: text/xml"); 
 
$host = "localhost"; 
$user = "********"; 
$pass = "******"; 
$database = "flashdb"; 
 
mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
mysql_select_db($database) or die("Could not find database."); 
 
$query = "SELECT * FROM portfolio ORDER BY date DESC"; 
$resultID = mysql_query($query) or die("Data not found."); 
 
$xml_output = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
"; 
$xml_output .= "<content>
"; 
 
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ 
	$row = mysql_fetch_assoc($resultID); 
	$xml_output .= "	<websites>
"; 
	$xml_output .= "		<project >" . $row['company'] . "</project>
"; 
	$xml_output .= "	</websites>
"; 
} 
 
$xml_output .= "</content>"; 
 
echo $xml_output; 
 
?>