<?php
session_start();
if (!isset($_SESSION['username'])) {
    echo "<script>window.top.location.href='index.php';</script>"; // Redirect parent window to login page
    exit();
}

include 'connect.php';

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css">-->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="fontawesome/css/all.min.css">
    <title>CUSTOMER CRUD OPERATION</title>
</head>
<body>
    <div class="container my-5">
    <button class="btn btn-primary"><a href="add_supplier.info.php" class="text-light">Add New Supplier<a></button>
    </div>
    <div class="container my-5">
    <table class="table table-hover">
  <thead>
    <tr>
      <th scope="col">SNo.</th>
      <th scope="col">Supplier Name</th>
      <th scope="col">Company</th>
      <th scope="col">Mobile</th>
      <th scope="col">Email</th>
      <th scope="col">Description</th>
    </tr>
  </thead>
  <tbody>

  <?php
    $sql= "select * from supplier_table";
    $result= mysqli_query($conn,$sql);
    if($result){

      //Initialize serial number
      $serealNo = 1;
       
        while($row=mysqli_fetch_assoc($result)){
            $sup_id=$row['sup_id'];
            $sup_name=$row['sup_name'];
            $sup_company=$row['sup_company'];
            $sup_mobile=$row['sup_mobile'];
            $sup_email=$row['sup_email'];
            $product_desc=$row['product_desc'];
           
            echo '<tr>
  
      <td>'.$serealNo++.'</td>
      <td>'.$sup_name.'</td>
      <td>'.$sup_company.'</td>
      <td>'.$sup_mobile.'</td>
      <td>'.$sup_email.'</td>
      <td>'.$product_desc.'</td>
    
      <td>
        <button class="btn btn-primary"><a href="update_supplier.php?updateid='.$sup_id.'" class="text-light"><i class="fas fa-edit"></i><a></button>
       
    </td>
    </tr>';
            
        }

    }




   ?>
    
    
  </tbody>
</table>

    </div>
    
</body>
</html>