Jump to content

Creating RSS.XML and have missing rows but no errors


ntroycondo

Recommended Posts

My RSS returns only the ID field with URL link. Missing title and description fields. No errors so not sure why it isn't displaying all the rows from the DB.

 

Code:

<?php

 

    $query = "SELECT * FROM rss_products ORDER BY ID desc LIMIT 5";

$result = @mysql_query ($query); // Run the query.

$num = mysql_num_rows($result);

if ($num != 0) {

$file = fopen("rss.xml", "w");

$_roll = "<?xml version=\"1.0\"?>\r\n";

$_roll .= "\t<rss version='2.0'>\r\n";

$_roll .= "\t\t<channel>\r\n";

$_roll .= "\t\t\t<title>Product News</title>\r\n";

$_roll .= "\t\t\t<link>http://www.somewebsite.com/</link>\r\n";

$_roll .= "\t\t\t<description>List latest product activity</description>\r\n";

$_roll .= "\t\t\t<language>en-us</language>\r\n";

 

 

while ($row = mysql_fetch_array($result)) {

if ($row["first_name"]) {

$_roll .= "\t\t\t\t<item>\r\n";

$headline = $row["ID"];

$content = $row["desc"];

$item_link = "http://www.somewebsite.com/";

$_roll .= "\t\t\t\t\t<title>$headline</title>\r\n";

$_roll .= "\t\t\t\t\t<description>$content</description>\r\n";

$_roll .= "\t\t\t\t\t<link>$item_link</link>\r\n";

$_roll .= "\t\t\t\t</item>\r\n";

}

}

 

$_roll .= "\t\t</channel>\r\n";

$_roll .= "\t</rss>\r\n";

fwrite($file, $_roll);

fclose($file);

echo "RSS has been written.  <a href=\"rss.xml\">View the RSS-XML.</a>";

} else {

echo "No Records found";

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.