<?php 
// we have to make our XML declaration this way or
// the some servers will think it is a PHP command
// instead of an XML command -- we will discuss how
// to tell whether you have this problem later
  echo "<?xml version=\"1.0\" encoding=\"UTF-8\"\x3f>";
  echo "\n";
?>

<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" 
  xml:lang="en" lang="en">
<link href="http://www.charleswore.com/css/cwo.css" rel="stylesheet" type="text/css" media="all">
<SCRIPT LANGUAGE="JavaScript" SRC="http://www.CharlesWOre.com/js/cwo.js">
</SCRIPT>

<body>

<?php
// Connecting, selecting database
$link = mysql_connect('db463660974.db.1and1.com', 'dbo463660974', 'anahata11')
   or die('Could not connect: ' . mysql_error());
mysql_select_db('db463660974') or die('Could not select database');

$getdate = date( "Y-m-d-h" );// Get the date.

// Performing SQL query
$query = 'SELECT file, location, af.name, href FROM tb_AudioFiles af, tb_Album where tb_Album.id=tb_album_id and startdate<=\''.$getdate.'\' and enddate>=\''.$getdate.'\' ORDER BY RAND(NOW())';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

   echo "\t<tr>\n";
   
	$fileURL=$line["file"];
	$location=$line["location"];
	$name=$line["name"];
	$albumURL=$line["href"];
	echo "<td>\n";
	echo "<a id=\"listen\" target=\"player\" href=\"";
	echo $location.$fileURL;
	echo "\"><img src=\"images/listen.png\" style='padding-right:7px;'></a><a id=\"listen\" target=\"player\" href=\"";
	echo $location.$fileURL;
	echo "\">" . $name;
	echo "</a> ";
	if ($albumURL!='NULL'){
	echo "<a href=\"javascript:NewWindow('".$albumURL."')\"><span id=\"buy\">(buy album)</span></a>";}
       	echo "</td>\n";
   
echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
?> 


</body>
</html>
