<?
header('Content-type: text/xml; charset=UTF-8')
?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel>
	<title>TheGauntlet.com Setlists</title>
	<link>http://www.thegauntlet.com</link>
	<description>thegauntlet.com</description>
<image>
	<title>TheGauntlet.com Setlists</title>
	<url>http://www.thegauntlet.com/thegauntlet_mini.gif</url>
	<link>http://www.thegauntlet.com/</link>
</image>
<changefreq>daily</changefreq>
<?
   include ("/home2/thegaunt/www/common/connectdb.php");
   function venue_name($t_id) {
   global $link;
   $sql = "SELECT venue FROM venues WHERE vid = '$t_id'" ;
   $sql_result = mysql_query ($sql, $link ) or die ('request "Could not execute SQL query"');
   $row = mysql_fetch_row( $sql_result );
   return $row[0];
 };

   function band_name($t_id) {
   global $link;
   $sql = "SELECT band FROM bands WHERE bid = '$t_id'" ;
   $sql_result = mysql_query ($sql, $link ) or die ('request "Could not execute SQL query"');
   $row = mysql_fetch_row( $sql_result );
   return $row[0];
 };

    function city_name($t_id) {
   global $link;
   $sql = "SELECT city FROM venues WHERE vid = '$t_id'" ;
   $sql_result = mysql_query ($sql, $link ) or die ('request "Could not execute SQL query"');
   $row = mysql_fetch_row( $sql_result );
   return $row[0];
 };

    function state_name($t_id) {
   global $link;
   $sql = "SELECT state FROM venues WHERE vid = '$t_id'" ;
   $sql_result = mysql_query ($sql, $link ) or die ('request "Could not execute SQL query"');
   $row = mysql_fetch_row( $sql_result );
   return $row[0];
 };
	$result = mysql_query( "SELECT * FROM setlists WHERE status=1 ORDER BY setlistid DESC LIMIT 0, 100 " );
	while ( $row = mysql_fetch_object( $result ) )
	{
    	$newname = band_name($row->bid);
		$patterns[0] = '/\ /';
		$patterns[1] = '/\'/';
		$patterns[2] = '/\&/';
		$replacements[0] = '-';
		$replacements[1] = '';
		$replacements[2] = '';
		$bandname = preg_replace($patterns, $replacements, $newname);
?>
	<item>
		<title><? echo band_name($row->bid); ?> - <? echo venue_name($row->vid); ?></title>
		<link>http://www.thegauntlet.com/setlists/<? echo "$row->bid"; ?>/<? echo "$row->setlistid"; ?>/<? echo $bandname; ?></link>
		<description><? echo "$row->term"; ?></description>
	</item>
<?
   };
?>
	</channel>
</rss>
