<?php
// Connect to the database
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "vijay";

// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (!$con) {
    die("Connection failed: " . mysqli_connect_error());
}

// Query to fetch payment data
$query = "SELECT * FROM payment";
$result = mysqli_query($con, $query);

if (!$result) {
    die("Error fetching data: " . mysqli_error($con));
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Payment Details</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f4f4f4;
            color: #333;
        }
        .container {
            margin-top: 30px;
        }
        .table {
            background-color: white;
            box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
        }
        .table th {
            background-color: #3498db;
            color: white;
        }
        .table td {
            text-align: center;
        }
        .logout-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            background-color: #e74c3c;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .logout-btn:hover {
            background-color: #c0392b;
        }
    </style>
</head>
<body>

<!-- Logout Button -->
<button class="logout-btn" onclick="location.href='logout.php'">Logout</button>

<div class="container">
    <h2 class="text-center my-4">Payment Details</h2>
    <table class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Order ID</th>
                <th>Payment ID</th>
                <th>Username</th>
                <th>Email</th>
                <th>Mobile</th>
                <th>Amount</th>
                <th>GST</th>
                <th>Total Amount</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody>
            <?php
            // Loop through the results and display each payment record
            while ($row = mysqli_fetch_assoc($result)) {
                echo "<tr>
                        <td>" . $row['id'] . "</td>
                        <td>" . $row['order_id'] . "</td>
                        <td>" . $row['payment_id'] . "</td>
                        <td>" . $row['username'] . "</td>
                        <td>" . $row['email'] . "</td>
                        <td>" . $row['mobile'] . "</td>
                        <td>" . $row['amount'] . "</td>
                        <td>" . $row['gst'] . "</td>
                        <td>" . $row['total_amount'] . "</td>
                        <td>" . $row['status'] . "</td>
                    </tr>";
            }
            ?>
        </tbody>
    </table>
</div>

</body>
</html>

<?php
// Close the connection
mysqli_close($con);
?>
