connect_error) { die("Connection failed: " . $conn->connect_error); } // Pagination settings from localStorage or defaults $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $limit = isset($_COOKIE['ticketsPerPage']) ? (int)$_COOKIE['ticketsPerPage'] : 15; $defaultSortColumn = isset($_COOKIE['defaultSortColumn']) ? $_COOKIE['defaultSortColumn'] : 'ticket_id'; $sortDirection = isset($_COOKIE['sortDirection']) ? $_COOKIE['sortDirection'] : 'desc'; $offset = ($page - 1) * $limit; // Get total number of tickets $totalTicketsQuery = "SELECT COUNT(*) as total FROM tickets"; $totalTicketsResult = $conn->query($totalTicketsQuery); $totalTickets = $totalTicketsResult->fetch_assoc()['total']; $totalPages = ceil($totalTickets / $limit); // Modify SQL to use these settings $sql = "SELECT * FROM tickets ORDER BY $defaultSortColumn $sortDirection LIMIT $limit OFFSET $offset"; $result = $conn->query($sql); ?>
| Ticket ID | Priority | Title | Category | Type | Status | Created | Updated |
|---|---|---|---|---|---|---|---|
| {$row['ticket_id']} | "; echo "{$row['priority']} | "; echo "{$row['title']} | "; echo "{$row['category']} | "; echo "{$row['type']} | "; echo "{$row['status']} | "; echo "" . date('Y-m-d H:i', strtotime($row['created_at'])) . " | "; echo "" . date('Y-m-d H:i', strtotime($row['updated_at'])) . " | "; echo "
| No tickets found | |||||||