<!DOCTYPE html>
<html>
<head>
  <title>DisplayAWSCOLONA</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->  
  <link rel="icon" type="image/png" href="images/icons/Final.ico"/>
<!--===============================================================================================-->
  <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
  <link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
  <link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
  <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
  <link rel="stylesheet" type="text/css" href="vendor/perfect-scrollbar/perfect-scrollbar.css">
<!--===============================================================================================-->
  <link rel="stylesheet" type="text/css" href="css/util.css">
  <link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
</head>
<body>
<style>
 .textQ1 {
 width: 10%;
 height: auto;
 border-radius: 8px;
 text-align: center;
} 
 .textQ2 {
 width: 20%;
 height: auto;
 border-radius: 8px;
 text-align: left;
}
 .textQ3 {
 width: 20%;
 height: auto;
 border-radius: 8px;
 text-align: left;
}  
 .textQ4 {
 width: 30%;
 height: auto;
 border-radius: 8px;
 text-align: left;
} .textQ5 {
 width: auto;
 height: auto;
 border-radius: 8px;
 text-align: left;
}

</style>
  <div class="limiter">
    <div class="container-table100">
      <div class="wrap-table100">
        <div class="table100">


<?php include("../conn.php"); ?>

<form action="index.php" method="get">
<input type="submit" value="Search">
<input type="text" id="Search" name="search" placeholder="Search by Phone number">
</form>


	<?php 
	 
  $text = isset($_GET['search']) ? $_GET['search'] : '';  

  if($text==''){
    $sqlcode = "SELECT * FROM `covidaws` " or die("Error:" . mysqli_error()); 
    $sqldebug = mysqli_query($con, $sqlcode); 
  ?> 

          <table>
            <thead>
              <tr class="table100-head">
                <th class="textQ1">No</th>
                <th class="textQ2">FullName</th>
                <th class="textQ3">Phone Number</th>
                <th class="textQ4">Aws No.</th>
                <th class="textQ5">Date</th>                
              </tr>
            </thead>
            <tbody>

  <?php
     while($sqlsum = mysqli_fetch_array($sqldebug)) { 
      ?>         

    <tr>
    <td class="textQ1"><?php echo $sqlsum["no"]; ?></td>
    <td class="textQ2"><?php echo $sqlsum["fullname"]; ?></td>
    <td class="textQ3"><?php echo $sqlsum["phoneno"]; ?></td>
    <td class="textQ4"><?php echo $sqlsum["awsno"]; ?></td>
    <td class="textQ5"><?php echo $sqlsum["dateaws"]; ?></td>  
    </tr>          
           

     <?php
      }
      ?>
 </tbody>
          </table>

<?php
  }else if($text!=''){
  
   $sqlcode = "SELECT count(`phoneno`) FROM `covidaws` WHERE `phoneno` LIKE '%".$text."%' " or die("Error:" . mysqli_error()); 
   $sqldebug = mysqli_query($con, $sqlcode); 
   $sqlsum = mysqli_fetch_array($sqldebug);

   if($sqlsum[0]>=1){


    $sqlcode = "SELECT * FROM `covidaws` WHERE `phoneno` LIKE '%".$text."%' " or die("Error:" . mysqli_error()); 
    $sqldebug = mysqli_query($con, $sqlcode); 
    ?>

    <table>
            <thead>
              <tr class="table100-head">
                <th class="textQ1">No</th>
                <th class="textQ2">FullName</th>
                <th class="textQ3">Phone Number</th>
                <th class="textQ4">Aws No.</th>
                <th class="textQ5">Date</th>                
              </tr>
            </thead>
            <tbody>

   <?php
     while($sqlsum = mysqli_fetch_array($sqldebug)) { 
       ?>
  <tr>
    <td class="textQ1"><?php echo $sqlsum["no"]; ?></td>
    <td class="textQ2"><?php echo $sqlsum["fullname"]; ?></td>
    <td class="textQ3"><?php echo $sqlsum["phoneno"]; ?></td>
    <td class="textQ4"><?php echo $sqlsum["awsno"]; ?></td>
    <td class="textQ5"><?php echo $sqlsum["dateaws"]; ?></td>  
    </tr>          
       <?php
      }
      ?>
 </tbody>
          </table>
<?php

   }else if($sqlsum[0]==0){

   $sqlcode = "SELECT * FROM `covidaws` WHERE `fullname` LIKE '%".$text."%' " or die("Error:" . mysqli_error()); 
   $sqldebug = mysqli_query($con, $sqlcode); 
   ?>
    <table>
            <thead>
              <tr class="table100-head">
                <th class="textQ1">No</th>
                <th class="textQ2">FullName</th>
                <th class="textQ3">Phone Number</th>
                <th class="textQ4">Aws No.</th>
                <th class="textQ5">Date</th>                
              </tr>
            </thead>
            <tbody>
   <?php
   
     while($sqlsum = mysqli_fetch_array($sqldebug)) { 
       ?>
<tr>
    <td class="textQ1"><?php echo $sqlsum["no"]; ?></td>
    <td class="textQ2"><?php echo $sqlsum["fullname"]; ?></td>
    <td class="textQ3"><?php echo $sqlsum["phoneno"]; ?></td>
    <td class="textQ4"><?php echo $sqlsum["awsno"]; ?></td>
    <td class="textQ5"><?php echo $sqlsum["dateaws"]; ?></td>  
    </tr>  

       <?php
      }
      ?>
 </tbody>
          </table>
<?php

   }
    
   
  

  } 

	?>

































        </div>
      </div>
    </div>
  </div>

<!--===============================================================================================-->  
  <script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
  <script src="vendor/bootstrap/js/popper.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
  <script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
  <script src="js/main.js"></script>
</body>
</html>