<?php
/*
This file prints the applicants applied for IEEE local memebership.
Restrict other user from administrator from seeing this page. 
Create a print friendly page shorted by last name, first name, 
and e-mail address and space for signature. 
*/
include("../includes/mysql_login.php");
session_start();
if(!isset($_SESSION['autheticate']))
{
	header("Location: ../index.php");
	exit;
}
if($_SESSION['admin'] == 0)
{
	header("location: ../index.php");
	exit;
}
$link = $_SERVER['PHP_SELF'];
echo "<table border=1 bordercolor=black>";
echo "<tr>";
echo "<td>ID </td>";
echo "<td> Name </td>";
echo "<td> Email </td>";
echo "<td> Major </td>";
echo "<td> Not Listed </td>";
echo "<td> Minor </td>";
echo "<td> College Year</td>";
echo "<td> Graduation Year</td>";
echo "<td> Comment </td>";
echo "<td> Date </td>";
echo "<td> Admin</td>";
echo "</td>";
$applicants = mysql_query("SELECT * FROM `application` ORDER BY last_name") or die (" Fail to query ");
if(!$applicants)
{
	echo "Query failed";
}
while($row_applicants = mysql_fetch_array($applicants))
{
	echo "<tr> <td>";
	echo $row_applicants['applicationid'] . "</td>";
	echo "<td>";
	echo $row_applicants['last_name'] . " , " . $row_applicants['first_name'] . "</td>";
	echo "<td>";
	echo $row_applicants['email'] . "</td>";
	echo " <td>";
	echo $row_applicants['major']. "</td>";
	echo "<td>";
	echo $row_applicants['other_major']. "</td>";
	echo "<td>";
	echo $row_applicants['minor']. "</td>";
	echo "<td>";
	echo $row_applicants['college_year']. "</td>";
	echo "<td>";
	echo $row_applicants['graduation_year']. "</td>";
	echo "<td>";
	echo $row_applicants['comment']. "</td>";
	echo "<td>";
	echo $row_applicants['date_applied']. "</td>";
	echo "<td>";
	echo "<a href=$link?which=$row_applicants[applicationid]&what=delete>Delete</a>";
	echo "</tr>";
}
if($_GET['what']==delete)
{
	$id = $_GET['which'];
	mysql_query("DELETE FROM application WHERE applicationid='$id'") or die("Fail to delete row");
	echo "<meta http-equiv = \"refresh\" content = \"0; URL=members.php\">";

}
?>