I'm creating an XML for an RSS feed. For some reason the loop isn't working. It only shows me the last post, not the LIMIT 10. But if I run it through feedvalidator.org I see all 10. Just not in Mac Mail which I use to read RSS feeds. (just remembered after pasting the code I removed the LIMIT 10 while testing so ignore that above).
Any thoughts? The loop looks fine to me. And it's showing in the validator.
Or a better way of achieving this would be awesome too.
$rssfeed = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$rssfeed .= '<rss version="2.0">';
$rssfeed .= '<channel>';
$rssfeed .= '<title>My Site Feed</title>';
$rssfeed .= '<link>http://www.mysite.com</link>';
$rssfeed .= '<description>News feed</description>';
$rssfeed .= '<language>en-us</language>';
$rssfeed .= '<copyright>Copyright (C) 2013 mysite.com</copyright>';
$connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
or die('Could not connect to database');
mysql_select_db(DB_NAME)
or die ('Could not select database');
$query = "SELECT * FROM table ORDER BY date DESC";
$result = mysql_query($query) or die ("Could not execute query");
while($row = mysql_fetch_array($result)) {
extract($row);
$rssfeed .= '<item>';
$rssfeed .= '<title>' . $title . '</title>';
$rssfeed .= '<description>' . $description. '</description>';
$rssfeed .= '<link>http://www.mysite.php</link>';
$rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", strtotime($date)) . '</pubDate>';
$rssfeed .= '</item>';
}
$rssfeed .= '</channel>';
$rssfeed .= '</rss>';
echo $rssfeed;
Thanks












