View Single Post
Old 01-31-2008, 01:30 AM  
Dynamix
G F Y not
 
Industry Role:
Join Date: Jan 2004
Location: MN
Posts: 2,910
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>';

?>
__________________

TGPFactory Full TGP Design & Installation Services
ICQ 250 142 484 · AIM TGPDynamix · Email: patrick (at) tgpfactory (dot) com
See who I am at AdultWhosWho.com!
Dynamix is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote