Hi,
This is my first attempt at creating an RSS feed from data in my MySQL database.
http://www.argyllnewmedia.co.uk/auction/test.php?id=05050000
Here's the code. It outputs the text in the tags in the XML header lines. Does anyobody know why?
<?
header("Content-type: text/xml");
include("connect.php");
$current_category = mysql_fetch_row(mysql_query("SELECT * FROM category WHERE id='$id'"));
function get_all_listings ($category_id_to_search)
{
global $res;
$result = mysql_query("SELECT id FROM item WHERE auction_end > now() AND location_id='$category_id_to_search'");
while ($item_row = mysql_fetch_row($result))
if ($item_row[0])
$res[]=$item_row[0];
$result2 = mysql_query("SELECT id FROM category WHERE parent_id='$category_id_to_search'");
while ($row = mysql_fetch_array($result2))
get_all_listings ($row[0]);
}
$output = "<?xml version=\"1.0\" ?>\n";
$output .="<rss version=\"2.0\">\n";
$output .="<channel><title>Title Test</title>\n";
$output .="<link>http://www.argyllnewmedia.co.uk/auction</link>\n";
$output .="<description>RSS Feed</description>\n";
$output .="<language>en-us</language>\n";
$output .="<copyright>Copyright 2004-2006 Argyll New Media</copyright>\n";
get_all_listings ($current_category[0]);
$res = implode(",",$res);
$item = mysql_query("SELECT * FROM item WHERE id IN ($res)");
while($row = mysql_fetch_row($item))
{
$output .= '<item><title>$row[1]</title></item>';
}
$output .= '</channel></rss>';
print $output;
?>
Thanks
Asa.