01-31-2008, 01:35 AM
|
|
|
FBOP Class Of 2013
Industry Role:
Join Date: Jan 2004
Location: bumfuck, ky
Posts: 35,562
|
Quote:
Originally Posted by Dynamix
Not sure why your dates are screwy, assuming they worked this code ought to do the trick:
Code:
<?
include_once "config.php";
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo '<rss version="2.0">';
echo '<channel>
<title>lyrics</title>
<description>music lyrics</description>
<link>http://www.domain.com/</link>';
$sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by lyric_id desc limit 20";
// Analyze date of latest entry
$date_chk= mysql_query("select submit_date from lyrics where approved='1' order by lyric_id desc limit 1");
$latest= mysql_fetch_array($date_chk);
$latest_date= split(" ",$latest['submit_date']);
if ($latest_date[0]!=date("Y-m-d")) $sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by rand() limit 20";
$ex_sql = mysql_query( $sql_query );
$num_rows = mysql_num_rows($ex_sql);
if ( $num_rows >= 1) {
while ($mysql_array = mysql_fetch_array($ex_sql)) {
echo '<item>
<link>http://www.domain.com/'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_artist']).'/'.$mysql_array['lyric_id'].'-'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_title']).'.html'.'</link>
<title>'.htmlspecialchars($mysql_array['lyric_artist']).' - '.htmlspecialchars($mysql_array['lyric_title']).'</title>
<lyrics><![CDATA['.htmlspecialchars($mysql_array['lryic_text']).']]></lyrics>
<guid>http://www.domain.com/'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_artist']).'/'.$mysql_array['lyric_id'].'-'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_title']).'.html'.'</guid>
</item>';
}
} else {
echo 'No latest lyrics available.';
}
echo '</channel></rss>';
?>
|
that is randomizing them every time it pulls the rss page up
http://lyrics.gamesandlyrics.com/rss.php
|
|
|