<?php
include('mysqli_con.php');
//show all user
if(isset($_POST['show'])){
$buyer_id = $_POST['show'];
$sqlShowReport = "SELECT * FROM report ";
$showData = mysqli_query($conn, $sqlShowReport);

if(mysqli_num_rows($showData) > 0){
  while($row = mysqli_fetch_assoc($showData)){
?>
<form class="form-inline navbar-search" method="post" action="reportSearchDeletePro.php" >
  <tr><td><center><h5><?php echo $row["report_id"]; ?> </h5></center></td>
      <td><center><h5><?php echo $row["buyer_id"];?></h5></center></td>
      <td><center><h5><?php echo $row["seller_id"];?></h5></center></td>
      <td><center><h5><?php echo  $row["status_report"];?></h5><center></td>
        <td><a onclick="return confirm('Are You Sure ?')">
          <center><button type="submit" class="btn" name ="delete" value="<?php echo $row["report_id"]; ?>" >DELETE</button></center>
        </td></tr></td>
  </form>
<?php }}}

//delete user and their items
if(isset($_POST['delete'])){
  $reportid = $_POST['delete'];
  $deleteReport = "DELETE FROM report WHERE report_id = '$reportid'";
  mysqli_query($conn, $deleteReport);
  ?>
  <meta http-equiv="refresh" content="0; URL='adminReport.php'">
  <?php
}
// search user by id
if(isset($_POST['search'])){
  $searchReport= $_POST['searchIDReport'];
  $sqlSearchReport = "SELECT * FROM report WHERE seller_id LIKE '%".$searchReport."%'";
  $searchResult = mysqli_query($conn, $sqlSearchReport);
  while($row = mysqli_fetch_array($searchResult)){?>
    <form class="form-inline navbar-search" method="post" action="reportSearchDeletePro.php" >
      <tr><td><center><h5><?php echo $row["report_id"]; ?> </h5></center></td>
          <td><center><h5><?php echo $row["buyer_id"];?> </h5><center></td>
          <td><center><h5><?php echo  $row["seller_id"]; ?></h5><center></td>
          <td><center><h5><?php echo  $row["status_report"]; ?></h5><center></td>

            <td><a onclick="return confirm('Are You Sure ?')">
              <center><button type="submit" class="btn" name ="delete" value="<?php echo $row["buyer_id"]; ?>" >DELETE</button></center>
            </td></tr></td>
      </form>
      <?php
  }} else {

  }
  ?>
