<html>
<head>
    <meta charset="utf-8"/>
    <title>PRAYATNA - Coord Event Attendees</title>
	<link rel="stylesheet" href="admin_table.css">
	<link href="https://fonts.googleapis.com/css2?family=Asap+Condensed&display=swap" rel="stylesheet">
	<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@500&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Arizonia&display=swap" rel="stylesheet">
</head>
<body>
<h1 class="login-title">Event</h1>
<?php
    require('db.php');
    session_start();
	$cmobile=$_SESSION['mobile'];
    // When form submitted, check and create user session.
        // Check user is exist in the database
		//$selectedRow=$_POST['selectdelete'];
		//$query    = "DELETE FROM coord WHERE cid='$selectedRow'";
if(isset($_POST['submitviewattendees'])){
//echo implode(", ",$selectdelete);
//echo $selectdelete[0];
  if(isset($_POST['selectviewattendees'])){
	  //echo $selectdelete[0];
    foreach($_POST['selectviewattendees'] as $eventid){
      //echo "id ".$delid." ";
	  //echo "id ".$mobile." ";
	  $ecode = stripslashes($eventid);    // removes backslashes
      $ecode = mysqli_real_escape_string($con, $ecode);
	  //echo "id ".$delid." ";
	  //echo "comp ".strcmp("PR101",'$addid')." - ";
	  
	  $query    = "SELECT * FROM `event` where ecode=left('$eventid',5)";
	  $result = mysqli_query($con, $query) or die(mysql_error());
        $rows = mysqli_num_rows($result);
		//$mobile=$_SESSION['mobile'];
        if ($rows > 0) {
			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>";
			
        }
		echo "<h3>Attendees are listed below:</h3><br/>";
	  $query1  = "SELECT * FROM `participant` where ecode=left('$eventid',5)";
	  $result1 = mysqli_query($con, $query1) or die(mysql_error());
        $rows1 = mysqli_num_rows($result1);
		//$mobile=$_SESSION['mobile'];
        if ($rows1 > 0) {
			echo "<table border='1'><tr><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>';
			       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>";
		}
    }
  }
  else
 {echo "<div class='admin_login_form'>
<h3>No events are Choosen</h3><br/>
</div>";
 }
 }
 

?>
<p></p>
<a href="coord_dashboard.php"> <input type = "button" value = "COORD DASHBOARD" class="add_button"></a>

</body>
</html>