Jump to content

RSS for web site


Recommended Posts

Hello,

 

I have the following php code that should return a rss page, but the problem is that nothing from my sql data base appears on the rss page. All the connection info are correct. Can you tell me why doesn't return any article??

Thanks

 

<?php $db = new mysqli("localhost", "user", "pass", "site_db"); ?>
<?php header('Content-type: text/xml'); ?>
<?php echo "<?";?>xml version="1.0" encoding="iso-8859-1"<?php echo "?>";?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Quantic Lab</title>
		<link>http://www.quanticlab.com</link>
		<description>Press Releases</description>
		<language>en-us</language>
		<copyright>2009 Quantic Lab</copyright>
		<pubDate>Tue, 10 Apr 2009 22:31:45 EDT</pubDate>
		<lastBuildDate>Tue, 10 Apr 2009 22:31:45 EDT</lastBuildDate>
		<category>Quality Assurance</category>
		<generator>QL RSS Generator</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.quanticlab.com/feed/Sigla_alb.jpg</url>
			<title>Quantic Lab</title>
			<link>http://www.quanticlab.com</link>
			<height>95</height>
			<width>133</width>
			<description>Quality Assurence</description>
		</image>
<?php

$query = "SELECT * FROM news";
$results = $db->query($query);
$number = $results->num_rows;

for ($i = 1; $i <= $number; $i++) {

$row = $results->fetch_assoc();

$title = $row['news_titlu'];
$description = $row['news_short'];
$link = "http://www.quanticlab.com/press.php?id_news=".$row['id_news'];
$date = date("r", $row['timestamp']);

?>
<item>
<title><?php echo $title; ?></title>
<description><?php echo $description; ?></description>
<link><?php echo $link; ?></link>
<pubDate><?php echo $date; ?></pubDate>
<guid><?php echo $link; ?></guid>
</item>
<?php

}

?>
</channel>
</rss>
<?php

$db->close();

?>

Link to comment
https://forums.phpfreaks.com/topic/153453-rss-for-web-site/
Share on other sites

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.