<html>
<head>
    <meta charset="utf-8"/>
    <title>PRAYATNA - User Deregister Event</title>
	<link rel="stylesheet" href="user_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>
<?php
    require('db.php');
    session_start();
	$mobile=$_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['submitdel'])){
//echo implode(", ",$selectdelete);
//echo $selectdelete[0];
  if(isset($_POST['selectdel'])){
	  //echo $selectdelete[0];
    foreach($_POST['selectdel'] as $delid){
      //echo "id ".$delid." ";
	  //echo "id ".$mobile." ";
	  $ecode = stripslashes($delid);    // removes backslashes
      $ecode = mysqli_real_escape_string($con, $ecode);
	  //echo "id ".$delid." ";
	  //echo "comp ".strcmp("PR101",'$addid')." - ";
	  $query    = "DELETE from `participant` where umobile='$mobile' AND ecode=left('$delid',5)";
	  //$query    = "SELECT * FROM `participant` where ecode=left('$addid',5)";
	  //$query    = "SELECT * FROM `participant` where strcmp(ecode,'$addid')";
	  	  //$query    = "SELECT * FROM `participant` where ecode like '$addid%' AND umobile like '$mobile%'";
		  //$addid = mysqli_real_escape_string($con,$addid);
		  //$mobile = mysqli_real_escape_string($con,$mobile);
		  //$query=sprintf("SELECT * FROM `participant` where ecode like '%s%%' AND umobile like '%s%%'", $addid,$mobile);
        
		$query    = "DELETE from `participant` where umobile='$mobile' AND ecode=left('$delid',5)";
		$result = mysqli_query($con, $query) or die(mysql_error());
        //$rows = mysqli_num_rows($result);
		  //echo "rows ".$rows ;
		//if($rows==1)
		//{
		//	$delEvent = "DELETE `participant` (umobile, ecode, attended) VALUES ('$mobile', '$addid', 0)";
		//	$result=mysqli_query($con,$addEvent) or die(mysql_error());
		//}
    }
  }
 }
 header("Location: user_add_event.php");
        //$result = mysqli_query($con, $query) or die(mysql_error());
            //echo "<div class='form'>
                  //<h3>Events Deleted</h3><br/>
				  //<p class='link'>Click here to <a href='user_add_event.php'>Go to User Dashboard</a> again.</p>
                  //</div>";
?>
</body>
</html>