PK

ADDRLIN : C:/Inetpub/vhosts/dharmayatra.co.in/httpdocs/admin/packages-old/
FLL :
Current File : C:/Inetpub/vhosts/dharmayatra.co.in/httpdocs/admin/packages-old/index.php

<?php
include('../includes/auth.php');
include('../../includes/db.php');
include('../includes/header.php');
include('../includes/sidebar.php');

// Pagination (CRM optimization ✅)
$limit = 10;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$offset = ($page - 1) * $limit;

// Fetch packages
$query = "SELECT id, title, price, duration 
          FROM packages 
          ORDER BY id DESC 
          LIMIT $limit OFFSET $offset";

$result = mysqli_query($conn, $query);

// Total count
$totalQuery = mysqli_query($conn, "SELECT COUNT(id) as total FROM packages");
$totalRow = mysqli_fetch_assoc($totalQuery);
$totalPages = ceil($totalRow['total'] / $limit);
?>

<div class="top-bar">
    <h2>📦 Tour Packages</h2>
    <a href="add.php" class="btn btn-primary">
        <i class="fa fa-plus"></i> Add Package
    </a>
</div>

<div class="card">
    <table>
        <tr>
            <th>ID</th>
            <th>Title</th>
            <th>Duration</th>
            <th>Price</th>
            <th>Action</th>
        </tr>

        <?php while($row = mysqli_fetch_assoc($result)) { ?>
        <tr>
            <td><?= $row['id'] ?></td>
            <td><?= $row['title'] ?></td>
            <td><?= $row['duration'] ?> Day(s)</td>
            <td>₹<?= number_format($row['price']) ?></td>
            <td>
                <a href="edit.php?id=<?= $row['id'] ?>" class="btn btn-warning">Edit</a>
                <a href="delete.php?id=<?= $row['id'] ?>" 
                   class="btn btn-danger"
                   onclick="return confirm('Delete this package?')">
                   Delete
                </a>
            </td>
        </tr>
        <?php } ?>
    </table>

    <!-- Pagination -->
    <div class="pagination">
        <?php for($i=1; $i<=$totalPages; $i++) { ?>
            <a href="?page=<?= $i ?>" class="<?= ($i == $page) ? 'active' : '' ?>">
                <?= $i ?>
            </a>
        <?php } ?>
    </div>
</div>

<?php include('../includes/footer.php'); ?>


PK 99