Reputation: 117
My code is...
$getMe = "SELECT ID, NewsType, Content, DATE_FORMAT(DateTime,'%a, %e %b %Y %T') as formatted_date FROM tblnews ORDER BY DateTime DESC LIMIT 15";
$articles = mysql_query($getMe) or die(mysql_error());
while ($article = mysql_fetch_array($articles)){
echo '<item>
<title>'.$article[NewsType].'</title>
<description><![CDATA['.$article[Content].']]></description>
<link>MySite.com</link>
<pubDate>'.$row[formatted_date].' GMT</pubDate>
</item>';
}
I tried to echo $row[formatted_date]
but it doesn't display anything.
BTW, I am making this for an xml file :)
Upvotes: 0
Views: 73
Reputation: 11984
I didnt see a variable $row
in your code.Also you have to keep the keys of the array in quotes. Probably you need to do the following
$getMe = "SELECT ID, NewsType, Content,
DATE_FORMAT(DateTime,'%a, %e %b %Y %T') as formatted_date
FROM tblnews ORDER BY DateTime DESC LIMIT 15";
$articles = mysql_query($getMe) or die(mysql_error());
while ($article = mysql_fetch_array($articles)){
echo '
<item>
<title>'.$article['NewsType'].'</title>
<description><![CDATA['.$article['Content'].']]></description>
<link>MySite.com</link>
<pubDate>'.$article['formatted_date'].' GMT</pubDate>
</item>';
}
Upvotes: 1