<?php
    require_once 'check_security.php';

    
       if(isset($_GET['game'])){
             $gamecode=$_GET['game'];
        if(isset($_GET['join'])){
          $m_id=$_GET['join'];
          $joinmatch = mysqli_query($conn,"SELECT * FROM matches WHERE m_id = '$m_id' and match_status='1'");
          $arra=array();
      while($row=mysqli_fetch_assoc($joinmatch)){
          $arra[]=$row;
      }
      if(sizeof($arra)<=0){
        header("Location: /fairb/match.php?game=$gamecode");
      }else{

        header("Location: /fairb/joinmatch.php?join=$m_id");
      }
      

        }
         
               $livemat = mysqli_query($conn,"SELECT * FROM matches WHERE match_status = '3' and game_id='$gamecode'"); 
    $upcomemat = mysqli_query($conn,"SELECT * FROM matches WHERE match_status = '1' and game_id='$gamecode'"); 
    $resultmat = mysqli_query($conn,"SELECT * FROM matches  ORDER BY m_id DESc"); 
    
   

           if($gamecode==1){
               $gamename="Bgmi Match";
               $logogg="unnamed.webp";
           }else if($gamecode==2){
              $gamename="free Fire Match"; 
              $logogg="unnamed(1).webp";
           }else if($gamecode==3){
                $gamename="Ludo King"; 
                 $logogg="unnamed(2).webp";
           }else{
                 header("Location: /fairb/");
           }
           
       }else{
              header("Location: /fairb/");
       }
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  	<link href="/adminnh/assist/css/matchpage.css" rel="stylesheet" type="text/css" />
  <title>Match</title>
</head>
<body>
    
    
    <style>
body{
  background-color: aliceblue;
  display: block;
}
*{
  padding: 0;
margin: 0;

box-sizing: border-box;
font-family: Canva Sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;;
text-decoration: none;

}
div.bodydivv div.tabdiv{
 
  align-items: center;
box-shadow: 10px;
box-shadow: 0px 5px 10px cadetblue;
border: 1px solid #ccc;
background-color: darkturquoise;
   
}
div.bodydivv div.tabdiv div.backbtn{


 display: flex;
   align-items: center;
padding: 7px;
 
}
div.bodydivv div.tabdiv div.backbtn h3{
    color: white;
    margin-left: 5px;
}
div.bodydivv div.tabdiv div.backbtn a{
 align-items: center;   
}
div.bodydivv div.tabdiv div.backbtn img{
  width: 40px;
  height: 40px;

}
div.bodydivv div.tabdiv div.divbtn{
  align-items: center;
  display: flex;
}
div.bodydivv div.tabdiv div.divbtn div.singlebtn{
  
  margin: auto;
  width: 31%;
  height: 100%;
  padding: 10px;
  text-align: center;
  border-radius: 0px 0px 10px 10px;
  border: none;
cursor: pointer;
  background-color: none;
  font-size: large;
}
div.bodydivv div.tabdiv div.divbtn div.active{
  
  margin: auto;
  width: 31%;
  height: 100%;
  padding: 10px;
  text-align: center;
  border-radius: 0px 0px 10px 10px;
  border: none;
cursor: pointer;
  background-color: blueviolet;
  font-size: large;
}
div.bodydivv div.tabdiv div.divbtn div.singlebtn:hover{
  background-color: blueviolet;
}
div.bodydivv div.tabdiv div.divbtn div.singlebtn button{
margin: auto;
border: none;
background-color: transparent;
color: white;
font-size: 20px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv{
  padding: 10px;
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      grid-gap: 2rem;
}
@media only screen and (max-width:945px){
  div.tabcontent div.matchlayoutdiv div.allmatchdiv{
  padding: 10px;
      display: grid;
      grid-template-columns: repeat(1, 1fr);
      grid-gap: 2rem;
}  
    
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv{
  padding: 7px;
  width: var(--s-full);
align-items: center;
box-shadow: 10px;
box-shadow: 0px 5px 10px cadetblue;
border-radius: 10px;
border: 1px solid #ccc;
background-color: white;


  
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner{
display: flex;
padding: 2px;
margin: 10px;
margin-left: 10px;


}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.imgdiv{
  margin-left: 10px;
  margin-right: 10px;
  border-radius: 50%;


}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.imgdiv img{
  border-radius: 50%;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.titletime h3{
  margin-bottom: 5px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.totALJOIN{
  text-align: right;
  width: max-content;
  margin: auto;
 
} 
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody{
  margin: 0px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1{
  margin-bottom: 15px;
  display: flex;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1 div.winpri{
  margin: auto;
  text-align: center;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1 div.winpri h3{
  font-style:unset;
  color: #616161;
  font-size: 17px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1 div.winpri p{
  margin: 5px;
 font-size: 20px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn{
  margin: 10px;
   display: grid;
      grid-template-columns: repeat(2, 1fr);
      grid-gap: 2rem;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn a {
    text-align: center;
}

div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn a div.joindivbtn{
  margin: auto;


}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn a div.joindivbtn button{
padding: 10px;
padding-left: 40px;
padding-right: 40px;
border-radius: 10px;
box-shadow: 10px;
border-radius: 10px;
border: 1px solid #e9dd36;
background-color: rgb(39, 187, 71);
color: white;
font-size: 19px;
text-align: center;
}



</style>
    
    
    
    
    
    
    
  <div class="bodydivv">
      
    <div class="tabdiv">
       <div class="backbtn">
           <a href="/fairb">
        <img src="https://fairbattle.earnmoreapp.in/adminnh/assist/icon/left.png"/>
       
        </a>
         <h3><?php echo $gamename; ?></h3>
       </div>
      <div class="divbtn">
        <div class="singlebtn"  class="tablinks" onclick="openCity(event, 'ongogingdiv')">
          <button>Ongoing</button>
        </div>
        <div class="singlebtn" id="up"  class="tablinks" onclick="openCity(event, 'upcomingdiv')">
          <button>Upcoming</button>
        </div>
        <div class="singlebtn"  class="tablinks" onclick="openCity(event, 'resulatdiv')">
          <button>Result</button>
        </div>
      
      
      </div>

    </div>
    <div class="alltabl">
      <div class="tabcontent" id="ongogingdiv">
        <div class="matchlayoutdiv">
          <div class="allmatchdiv">
            <?php
           
          while($row=mysqli_fetch_assoc($livemat)){
?>
  <div class="singlematchdiv">
        
  <div class="haderbanner">
    <div class="imgdiv">
      <img src="<?php echo $logogg; ?>" />
    </div>
    <div class="titletime">
      <h3><?php echo $row["match_name"]; ?></h3>
      <p><?php echo $row["match_time"]; ?></p>
    </div>
    <div class="totALJOIN">
      <p><?php echo $row["total_player"]; ?>/<?php echo $row["no_of_player"]; ?></p>
    </div>
  </div>
  
  <div class="matchbody">
    <div class="threemain1">
      <div class="winpri">
        <h3>WIN PRICE</h3>
        <p>₹<?php echo $row["win_prize"]; ?></p>
      </div>
      <div class="winpri">
        <h3>PER KILL</h3>
        <p>₹<?php echo $row["per_kill"]; ?></p>
      </div>
      <div class="winpri">
        <h3>ENTRY FEE</h3>
        <p>₹<?php echo $row["entry_fee"]; ?></p>
      </div>
    </div>
  
    <div class="threemain1">
      <div class="winpri">
        <h3>TYPE</h3>
        <p><?php echo $row["type"]; ?></p>
      </div>
      <div class="winpri">
        <h3>VERSION</h3>
        <p><?php echo $row["match_type"]; ?></p>
      </div>
      <div class="winpri">
        <h3>MAP</h3>
        <p><?php echo $row["MAP"]; ?></p>
      </div>
    </div>
  
  </div>
   <?php
    $matchid=$row['m_id'];
      $joncomatjo = mysqli_query($conn,"SELECT * FROM match_join_member WHERE member_id = '$id' and match_id='$matchid'");
          $oncomarra=array();
      while($rowson=mysqli_fetch_assoc($joncomatjo)){
          $oncomarra[]=$rowson;
            $joinhh="";
      }
      if(sizeof($oncomarra)<=0){
       $onjointxt="NOT JOIN";
       $onjoinhh="full";
      }else{
 $onjointxt="JOINED";
 $onjoinhh="full";
       
      }
    
    ?>
  <div class="footerbtn">
   <a href="<?php echo $onjoinhh; ?>match.php?game=<?php echo $gamecode;?>&join=<?php echo $row['m_id'];?>">
      <div class="joindivbtn" >
      <button><?php echo $onjointxt; ?></button>
    </div>
    </a>
     <a href="fullmatch.php?game=<?php echo $gamecode;?>&join=<?php echo $row['m_id'];?>">
      <div class="joindivbtn" >
      <button>Details</button>
    </div>
    </a>
  
  </div>
  
              </div>
<?php
}

?>


          </div>
        </div>
      </div>
      <div class="tabcontent"id="upcomingdiv">
        <div class="matchlayoutdiv">
          <div class="allmatchdiv">
            <?php
while($row=mysqli_fetch_assoc($upcomemat)){
  ?>
    <div class="singlematchdiv">
          
    <div class="haderbanner">
      <div class="imgdiv">
        <img src="<?php  echo $logogg; ?>" />
      </div>
      <div class="titletime">
        <h3><?php echo $row["match_name"]; ?></h3>
        <p><?php echo $row["match_time"]; ?></p>
      </div>
      <div class="totALJOIN">
        <p><?php echo $row["total_player"]; ?>/<?php echo $row["no_of_player"]; ?></p>
      </div>
    </div>
    
    <div class="matchbody">
      <div class="threemain1">
        <div class="winpri">
          <h3>WIN PRICE</h3>
          <p>₹<?php echo $row["win_prize"]; ?></p>
        </div>
        <div class="winpri">
          <h3>PER KILL</h3>
          <p>₹<?php echo $row["per_kill"]; ?></p>
        </div>
        <div class="winpri">
          <h3>ENTRY FEE</h3>
          <p>₹<?php echo $row["entry_fee"]; ?></p>
        </div>
      </div>
    
      <div class="threemain1">
        <div class="winpri">
          <h3>TYPE</h3>
          <p><?php echo $row["type"]; ?></p>
        </div>
        <div class="winpri">
          <h3>VERSION</h3>
          <p><?php echo $row["match_type"]; ?></p>
        </div>
        <div class="winpri">
          <h3>MAP</h3>
          <p><?php echo $row["MAP"]; ?></p>
        </div>
      </div>
    
    </div>
    <?php
    $matchid=$row['m_id'];
      $jupcomatjo = mysqli_query($conn,"SELECT * FROM match_join_member WHERE member_id = '$id' and match_id='$matchid'");
          $upcomarra=array();
      while($rowsup=mysqli_fetch_assoc($jupcomatjo)){
          $upcomarra=$rowsup;
            $joinhh="";
      }
      if(sizeof($upcomarra)<=0){
       $upjointxt="JOIN";
       $upjoinhh="";
      }else{
 $upjointxt="JOINED";
 $upjoinhh="full";
       
      }
    
    ?>
    <div class="footerbtn">
  <a href="<?php echo $upjoinhh;?>match.php?game=<?php echo $gamecode;?>&join=<?php echo $row['m_id'];?>">
      <div class="joindivbtn" >
      <button><?php echo $upjointxt;?></button>
    </div>
    </a>
    <a href="fullmatch.php?game=<?php echo $gamecode;?>&join=<?php echo $row['m_id'];?>">
      <div class="joindivbtn" >
      <button>Details</button>
    </div>
    </a>
    
    </div>
    
                </div>
  <?php
  }
  
  ?>


          </div>
        </div>
      </div>
      <div class="tabcontent" id="resulatdiv">
        <div class="matchlayoutdiv">
          <div class="allmatchdiv">
           <?php
while($row=mysqli_fetch_assoc($resultmat)){
    if($row["match_status"]==2 And $row["game_id"]==$gamecode){
?>
  <div class="singlematchdiv">
        
  <div class="haderbanner">
    <div class="imgdiv">
      <img src="<?php echo $logogg; ?>" />
    </div>
    <div class="titletime">
      <h3><?php echo $row["match_name"]; ?></h3>
      <p><?php echo $row["match_time"]; ?></p>
    </div>
    <div class="totALJOIN">
      <p><?php echo $row["no_of_player"]; ?>/<?php echo $row["total_player"]; ?></p>
    </div>
  </div>
  
  <div class="matchbody">
    <div class="threemain1">
      <div class="winpri">
        <h3>WIN PRICE</h3>
        <p>₹<?php echo $row["win_prize"]; ?></p>
      </div>
      <div class="winpri">
        <h3>PER KILL</h3>
        <p>₹<?php echo $row["per_kill"]; ?></p>
      </div>
      <div class="winpri">
        <h3>ENTRY FEE</h3>
        <p>₹<?php echo $row["entry_fee"]; ?></p>
      </div>
    </div>
  
    <div class="threemain1">
      <div class="winpri">
        <h3>TYPE</h3>
        <p><?php echo $row["type"]; ?></p>
      </div>
      <div class="winpri">
        <h3>VERSION</h3>
        <p><?php echo $row["match_type"]; ?></p>
      </div>
      <div class="winpri">
        <h3>MAP</h3>
        <p><?php echo $row["MAP"]; ?></p>
      </div>
    </div>
  
  </div>
   <?php
    $matchid=$row['m_id'];
      $jrecomatjo = mysqli_query($conn,"SELECT * FROM match_join_member WHERE member_id = '$id' and match_id='$matchid'");
          $recomarra=array();
      while($rowsre=mysqli_fetch_assoc($jrecomatjo)){
          $recomarra=$rowsre;
            $joinhh="";
      }
      if(sizeof($recomarra)<=0){
       $rejointxt="NOT JOIN";
       $rejoinhh="full";
      }else{
 $rejointxt="JOINED";
 $rejoinhh="full";
       
      }
    
    ?>
  <div class="footerbtn">
   <a href="<?php echo $rejoinhh; ?>match.php?game=<?php echo $gamecode;?>&join=<?php echo $row['m_id'];?>">
      <div class="joindivbtn" >
      <button><?php echo $rejointxt; ?></button>
    </div>
    </a>
    <a href="fullmatch.php?game=<?php echo $gamecode;?>&join=<?php echo $row['m_id'];?>">
      <div class="joindivbtn" >
      <button>Details</button>
    </div>
    </a>
  
  </div>
  
              </div>
<?php
}}

?>




           
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
<style>
body{
  background-color: aliceblue;
  display: block;
}
*{
  padding: 0;
margin: 0;

box-sizing: border-box;
font-family: Canva Sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;;
text-decoration: none;

}
div.bodydivv div.tabdiv{
 
  align-items: center;
box-shadow: 10px;
box-shadow: 0px 5px 10px cadetblue;
border: 1px solid #ccc;
background-color: darkturquoise;
   
}
div.bodydivv div.tabdiv div.backbtn{


 display: flex;
   align-items: center;
padding: 7px;
 
}
div.bodydivv div.tabdiv div.backbtn h3{
    color: white;
    margin-left: 5px;
}
div.bodydivv div.tabdiv div.backbtn a{
 align-items: center;   
}
div.bodydivv div.tabdiv div.backbtn img{
  width: 40px;
  height: 40px;

}
div.bodydivv div.tabdiv div.divbtn{
  align-items: center;
  display: flex;
}
div.bodydivv div.tabdiv div.divbtn div.singlebtn{
  
  margin: auto;
  width: 31%;
  height: 100%;
  padding: 10px;
  text-align: center;
  border-radius: 0px 0px 10px 10px;
  border: none;
cursor: pointer;
  background-color: none;
  font-size: large;
}
div.bodydivv div.tabdiv div.divbtn div.active{
  
  margin: auto;
  width: 31%;
  height: 100%;
  padding: 10px;
  text-align: center;
  border-radius: 0px 0px 10px 10px;
  border: none;
cursor: pointer;
  background-color: blueviolet;
  font-size: large;
}
div.bodydivv div.tabdiv div.divbtn div.singlebtn:hover{
  background-color: blueviolet;
}
div.bodydivv div.tabdiv div.divbtn div.singlebtn button{
margin: auto;
border: none;
background-color: transparent;
color: white;
font-size: 20px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv{
  padding: 10px;
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      grid-gap: 2rem;
}
@media only screen and (max-width:945px){
  div.tabcontent div.matchlayoutdiv div.allmatchdiv{
  padding: 10px;
      display: grid;
      grid-template-columns: repeat(1, 1fr);
      grid-gap: 2rem;
}  
    
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv{
  padding: 7px;
  width: var(--s-full);
align-items: center;
box-shadow: 10px;
box-shadow: 0px 5px 10px cadetblue;
border-radius: 10px;
border: 1px solid #ccc;
background-color: white;


  
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner{
display: flex;
padding: 2px;
margin: 10px;
margin-left: 10px;


}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.imgdiv{
  margin-left: 10px;
  margin-right: 10px;
  border-radius: 50%;


}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.imgdiv img{
  border-radius: 50%;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.titletime h3{
  margin-bottom: 5px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.haderbanner div.totALJOIN{
  text-align: right;
  width: max-content;
  margin: auto;
 
} 
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody{
  margin: 0px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1{
  margin-bottom: 15px;
  display: flex;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1 div.winpri{
  margin: auto;
  text-align: center;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1 div.winpri h3{
  font-style:unset;
  color: #616161;
  font-size: 17px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv  div.matchbody div.threemain1 div.winpri p{
  margin: 5px;
 font-size: 20px;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn{
  margin: 10px;
   display: grid;
      grid-template-columns: repeat(2, 1fr);
      grid-gap: 2rem;
}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn a {
    text-align: center;
}

div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn a div.joindivbtn{
  margin: auto;


}
div.tabcontent div.matchlayoutdiv div.allmatchdiv div.singlematchdiv div.footerbtn a div.joindivbtn button{
padding: 10px;
padding-left: 40px;
padding-right: 40px;
border-radius: 10px;
box-shadow: 10px;
border-radius: 10px;
border: 1px solid #e9dd36;
background-color: rgb(39, 187, 71);
color: white;
font-size: 19px;
text-align: center;
}



</style>
<script>
 document. getElementById("up").click();
  function openCity(evt, cityName) {
     
    var i, tabcontent, tablinks;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("singlebtn");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");
  }
  document.getElementById(cityName).style.display = "block";
  evt.currentTarget.className += " active";
 
  }
  </script>
</html>