prepare("SELECT * FROM categories WHERE slug = :slug AND status = 1 LIMIT 1"); $stmt->execute([':slug' => $slug]); $category = $stmt->fetch(); if (!$category) { header("Location: " . BASE_URL); exit(); } $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $limit = 10; $offset = ($page - 1) * $limit; $filter_date = $_GET['date'] ?? ''; $query_parts = "FROM posts p JOIN categories c ON p.category_id = c.id JOIN users u ON p.author_id = u.id WHERE c.slug = :slug AND p.status = 'published'"; if (!empty($filter_date)) { $query_parts .= " AND DATE(p.published_at) = :filter_date"; } $count_sql = "SELECT COUNT(*) " . $query_parts; $count_stmt = $conn->prepare($count_sql); $count_params = [':slug' => $slug]; if (!empty($filter_date)) $count_params[':filter_date'] = $filter_date; $count_stmt->execute($count_params); $total_posts = $count_stmt->fetchColumn(); $total_pages = ceil($total_posts / $limit); $sql = "SELECT p.*, c.name as category_name, c.color as category_color, u.name as author_name " . $query_parts . " ORDER BY p.published_at DESC LIMIT :limit OFFSET :offset"; $stmt = $conn->prepare($sql); $stmt->bindValue(':slug', $slug); if (!empty($filter_date)) $stmt->bindValue(':filter_date', $filter_date); $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $posts = $stmt->fetchAll(); $page_title = $category['name']; require_once 'layouts/header.php'; ?>

0): ?> 1): ?>
1): ?>

No articles found

Try adjusting your filters or check back later.

Back to Home