Lid |
|
Hey allen,
ik heb volgend script voor mijn RSS automatisch te laden aan de hand van de 10 laatste nieuwsitems in de database.
Echter werkt het niet... Iemand een idee waar ik fout zit?
Alvast bedankt!
CODE RSS.PHP
<?php
// Database settings
$dbhost = "localhost";
$db = "database";
$username = "login";
$dbww = "password";
$connection = mysql_connect("$dbhost","$username","$dbww");
mysql_select_db("$db");
// Start the RSS Feed
header('Content-type: text/xml'); // Must declare the content type
echo '<?xml version=\'1.0\' encoding=\'UTF-8\'?>';
// Set RSS version.
echo '
<rss version=\'2.0\'> ';
// Start the XML.
echo '
<channel>
<title>TITEL WEBSITE</title>
<link>http://www.mijnsite.be</link>';
// Query database and select the last 10 entries.
$sqlnews = mysql_query('select * from 2012_newsitem order by id desc limit 10');
while($data = mysql_fetch_array($sqlnews)){
echo '
<item>
<link>http://www.mijnsite.be/2012/index.php?p=artikel&id='.$data['id'].'</link>
<title>'.$data['titel'].'</title>
<description>'.$data['tekst'].'</description>
</item>';
}
echo '
</channel>
</rss>';
?>
<?php // Database settings $dbhost = "localhost"; $db = "database"; $username = "login"; $dbww = "password"; // Start the RSS Feed header('Content-type: text/xml'); // Must declare the content type echo '<?xml version=\'1.0\ ' encoding=\'UTF -8\ '?>'; // Set RSS version. <rss version=\'2.0\'> '; // Start the XML. <channel> <title>TITEL WEBSITE</title> <link>http://www.mijnsite.be</link>'; // Query database and select the last 10 entries. $sqlnews = mysql_query('select * from 2012_newsitem order by id desc limit 10'); <item> <link>http://www.mijnsite.be/2012/index.php?p=artikel&id='.$data['id'].'</link> <title>'.$data['titel'].'</title> <description>'.$data['tekst'].'</description> </item>'; } </channel> </rss>'; ?>
|