diff --git a/content/showCategory.php b/content/showCategory.php index a684f21..c3625a2 100644 --- a/content/showCategory.php +++ b/content/showCategory.php @@ -1,32 +1,194 @@ + +if(isset($articles)){ + $totalResultsCount = count($articles); + + $limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10; + if (!in_array($limit, [10, 20, 50, 100])) { + $limit = 10; + } + +// Gesamtseitenzahl + $totalPages = max(1, ceil($totalResultsCount / $limit)); + +// Aktuelle Seite auslesen und validieren + $currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1; + if ($currentPage < 1) { + $currentPage = 1; + } elseif ($currentPage > $totalPages) { + $currentPage = $totalPages; + } + +// Startpunkt im Array berechnen (Offset) + $offset = ($currentPage - 1) * $limit; + +// Nur die Ergebnisse für die aktuelle Seite ausschneiden +//$results = array_slice($all_results, $offset, $limit); + $results = $articles; + $resultCount = count($results); +} + +?> + + +