hjkhjkjhkhjkgjghjhgjhgjghjhghjghjhgjjnbvnvbnvk
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
wjcvelqp
/
biblog
/
Upload FileeE
HOME
<?php require_once 'config/database.php'; require_once 'includes/functions.php'; $slug = $_GET['slug'] ?? ''; $stmt = $pdo->prepare("SELECT * FROM categories WHERE slug = ?"); $stmt->execute([$slug]); $category = $stmt->fetch(); if (!$category) { die("Category not found!"); } $stmt = $pdo->prepare("SELECT p.*, c.name as category_name FROM posts p JOIN categories c ON p.category_id = c.id WHERE c.slug = ? ORDER BY p.created_at DESC"); $stmt->execute([$slug]); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <?php include 'includes/header.php'; ?> <div class="max-w-7xl mx-auto px-4 py-8"> <h1 class="text-4xl font-bold text-green-800 mb-8"><?= htmlspecialchars($category['name']) ?> News</h1> <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6"> <?php foreach($posts as $post): ?> <div class="bg-white rounded-xl overflow-hidden shadow hover:shadow-xl transition"> <?php if($post['featured_image']): ?> <img src="uploads/<?= htmlspecialchars($post['featured_image']) ?>" class="w-full h-56 object-cover"> <?php endif; ?> <div class="p-5"> <h3 class="font-semibold line-clamp-3"><?= htmlspecialchars($post['title']) ?></h3> <div class="flex justify-between mt-4 text-sm"> <span class="text-gray-500"><?= $post['views'] ?> views</span> <a href="single.php?id=<?= $post['id'] ?>&slug=<?= $post['slug'] ?>" class="text-green-700 font-medium">Read more →</a> </div> </div> </div> <?php endforeach; ?> </div> </div> <?php include 'includes/footer.php'; ?>