<?php session_start();
if(isset($_SESSION['email']))
{
echo "<p style='font-family: calibri;color: black;font-size: 14px;'>";
echo "";
echo "</p>";
}
else
{
	header( "Location: login.php" ); 
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
 </head>
 <style>
  p{
	  font-family: Calibri;
	  color: black;
	  font-size: 20;
	}
 td
{
	font-family: calibri;
	color: black;
	font-size: 20;
	text-align:center;
	background-image:url('lightgray.jpg');
	background-size:100% 100%;
	background-repeat:no-repeat;
}
</style>
 <body>
  <?php error_reporting (E_ALL ^ E_NOTICE);
  $con= mysql_connect("localhost:3306","","");
if (!$con)
{
	die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
  $rankres=mysql_query("select * from leaderboard order by position asc;");
  $ranknum=mysql_num_rows($rankres);
  $i=0;
  while($row = mysql_fetch_array($rankres))
	{
		$email[$i]=$row['email'];
		$position[$i]=$row['position'];
		$i++;
		
	}
  echo "<p>";
  echo "THIS WEEK'S WINNER IS ".$email[0]."</br></br>";
  echo "LEADERBOARD:</br>";
  echo "<table>";
  echo "<tr>";
  echo "<td>";
  echo "POSITION";
  echo "</td>";
  echo "<td>";
  echo "USER";
  echo "</td>";
  echo "</tr>";
  for($j=0;$j<$ranknum;$j++)
  {
  echo "<tr><td>$position[$j]</td><td>$email[$j]</td></tr>";
  }
  echo "</table>";
  echo "</p>";
  mysql_close($con);
  ?>
 </body>
</html>
