hjkhjkjhkhjkgjghjhgjhgjghjhghjghjhgjjnbvnvbnvk
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
wjcvelqp
/
biblog
/
Upload FileeE
HOME
<?php require_once 'config/database.php'; require_once 'includes/functions.php'; $query = trim($_GET['q'] ?? ''); $posts = []; if ($query) { $stmt = $pdo->prepare("SELECT p.*, c.name as category_name FROM posts p LEFT JOIN categories c ON p.category_id = c.id WHERE p.title LIKE ? OR p.content LIKE ? ORDER BY p.created_at DESC"); $search_term = "%$query%"; $stmt->execute([$search_term, $search_term]); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); } ?> <?php include 'includes/header.php'; ?> <div class="max-w-7xl mx-auto px-4 py-10"> <h1 class="text-3xl font-bold mb-2">Search Results for: <span class="text-green-800">"<?= htmlspecialchars($query) ?>"</span></h1> <?php if(!empty($posts)): ?> <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6"> <?php foreach($posts as $post): ?> <!-- Same card as in index.php --> <div class="bg-white rounded-xl overflow-hidden shadow"> <?php if($post['featured_image']): ?> <img src="uploads/<?= htmlspecialchars($post['featured_image']) ?>" class="w-full h-48 object-cover"> <?php endif; ?> <div class="p-5"> <h3 class="font-semibold"><?= htmlspecialchars($post['title']) ?></h3> <p class="text-sm text-gray-500 mt-3"><?= $post['views'] ?> views</p> <a href="single.php?id=<?= $post['id'] ?>" class="block mt-4 text-green-700">Read Full Article →</a> </div> </div> <?php endforeach; ?> </div> <?php else: ?> <p class="text-xl text-gray-600">No results found for "<?= htmlspecialchars($query) ?>". Try different keywords.</p> <?php endif; ?> </div> <?php include 'includes/footer.php'; ?>