<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php session_start();
if(isset($_SESSION['email']))
{
echo "";
}
else
{
	header( "Location: login.php" ); 
}
?>
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <style>
  
td
{
	font-family: calibri;
	color: black;
	font-size: 20;
	text-align:left;
	background-image:url('lightgray.jpg');
	background-size:100% 100%;
	background-repeat:no-repeat;
}
  </style>
  <script type="text/javascript">
  function submitform()
  {
	document.create.submit();
  }
  function postfun(j)
  {
	  document.finalsub.postf.value=j;
	  document.finalsub.submit();
  }
  </script>
 </head>
 <body>
 <form name="create" action="createthread.php">
 <input type="button" value="New Topic" onclick="submitform()"/>
 </form>
  <?php
 $con = mysql_connect("localhost:3306","","");
	if (!$con)
	{
		die('Could not connect: ' . mysql_error());
	}
	mysql_select_db("test", $con);

$threadresult=mysql_query("select * from thread;");
$threadnumber=mysql_num_rows($threadresult);
$i=0;
while($row = mysql_fetch_array($threadresult))
{
	$threadowner[$i]=$row['threadowner'];
	$created[$i]=$row['createdDate'];
	$subject[$i]=$row['subject'];
	$threadid[$i]=$row['threadid'];
	$i++;
}
echo "<form name='finalsub' action='post.php' method='post'>";

for($j=0;$j<$threadnumber;$j++)
{
	
	echo "<table style='border:2px solid black' width='100%'>";
	echo "<tr><td width='80%'>";
	echo "<a href='#' onclick='postfun($threadid[$j])'>$subject[$j]</a>"."</td>";
	echo "<td text-align:right width='20%' style='font-size:10'><i>by"."</br>".$threadowner[$j]."</i></br></br>";
	echo "</td></tr>";
	echo "</table></br>";
	
}

echo "<input type='hidden' name='postf'/>";
echo "</form>";
?>
 </body>
</html>
