<html>
<head>
    <meta charset="utf-8"/>
    <title>Admin Login - Prayatna' 23</title>
</head>
<body>
<?php
    require('db.php');
    session_start();
    // When form submitted, check and create user session.
        // Check user is exist in the database
		$query    = "SELECT * FROM `event`";
        $result = mysqli_query($con, $query) or die(mysql_error());
        $rows = mysqli_num_rows($result);
        if ($rows > 0) {
			
            //echo "<table border='1'><tr><th>VIEW</th><th>EVENT CODE</th><th>EVENT NAME</th><th>VENUE</th><th>DATE</th><th>START TIME</th><th>EVENT DURATION</th><th>COORDINATOR NAME</th></tr>";
			echo "<table border='1'><tr><th>EVENT CODE</th><th>EVENT NAME</th><th>VENUE</th><th>DATE</th><th>START TIME</th><th>EVENT DURATION</th></tr>";
			while($record = mysqli_fetch_array($result))
			{
	        echo '<tr>';
			echo "<td><center>" . $record['ecode'] . "</center></td><td><center>" . $record['ename'] . "</center></td><td><center>" . $record['venue'] . "</center></td><td><center>" . $record['edate'] . "</center></td><td><center>" . $record['stime'] . "</center></td><td><center>" . $record['duration'] . "</center></td></tr>";
			}
			echo "</table><br><br>";

            echo '</form>';
              
        } else {
            echo "<div class='form'>
                  <h3>No events are added</h3><br/>
				  <p class='link'>Click here to <a href='coord_dashboard.php'>Go to Coordinator Dashboard</a> again.</p>
                  </div>";
        }

		$query1  = "SELECT * FROM `participant` where ecode=left('$attendedid',5)";
	  $result1 = mysqli_query($con, $query1) or die(mysql_error());
        $rows1 = mysqli_num_rows($result1);
		//$mobile=$_SESSION['mobile'];
        if ($rows1 > 0) {
			echo '<form action = "coord_user_attendance_db.php" method = "POST" name = "giveattendanceform">';
			echo "<table border='1'><tr><th>ATTENDED</th><th>PARTICIPANT NAME</th><th>YEAR</th><th>COLLEGE</th><th>DEPARTMENT</th><th>MOBILE</th></tr>";
			while($record1 = mysqli_fetch_array($result1))
			{
				$sql1    = "SELECT * FROM `user` WHERE mobile='$record1[umobile]'" ;
                $sqlresult1 = mysqli_query($con, $sql1) or die(mysql_error());
                $sqlrows1 = mysqli_num_rows($sqlresult1);
				while($sqlrecord1 = mysqli_fetch_array($sqlresult1))
				{
	               echo '<tr><td><center><input type = "radio" style = "inline" name ="selectviewattendees[]" value="'.$record['ecode'].'>"</td></center>';
			       echo "<td><center>" . $sqlrecord1['uname'] . "</center></td><td><center>" . $sqlrecord1['year'] . "</center></td><td><center>" . $sqlrecord1['college'] . "</center></td><td><center>" . $sqlrecord1['dept'] . "</center></td><td><center>" . $sqlrecord1['mobile'] . "</center></td></tr>";
				}
			echo "</table><br>";
			echo '<input type = "submit" value = "Add Event" name = "submitviewattendees">';
        }
		}

        //$result = mysqli_query($con, $query) or die(mysql_error());
            echo "<div class='form'>
				  <p class='link'>Click here to <a href='coord_dashboard.php'>Go to Coordinator Dashboard</a> again.</p>
                  </div>";		
?>
				  <p class='link'>Click here to <a href='user_logout.php'>Logout</a> again.</p>
</body>
</html>