prepare($countSql); $countStmt->execute($params); $totalDrills = $countStmt->fetchColumn(); $totalPages = ceil($totalDrills / $drillsPerPage); // Add ordering and pagination to the main query $sql .= " ORDER BY created_at DESC LIMIT :limit OFFSET :offset"; $stmt = $pdo->prepare($sql); $stmt->bindValue(':userId', $userId, PDO::PARAM_INT); // Bind filter parameters foreach ($params as $key => $value) { $stmt->bindValue($key + 1, $value); } // Bind pagination parameters $stmt->bindValue(':limit', $drillsPerPage, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $drills = $stmt->fetchAll(PDO::FETCH_ASSOC); // Fetch distinct filter values for dropdowns $ageGroups = $pdo->query("SELECT DISTINCT age_group FROM drills WHERE is_public = TRUE ORDER BY age_group")->fetchAll(PDO::FETCH_COLUMN); $difficulties = $pdo->query("SELECT DISTINCT difficulty FROM drills WHERE is_public = TRUE ORDER BY difficulty")->fetchAll(PDO::FETCH_COLUMN); } catch (PDOException $e) { // For production, you would log this error and show a generic error page. die("Error fetching drills: " . $e->getMessage()); } ?>

Find Your Perfect Drill

Create a Drill Browse All

All Drills

No drills found matching your criteria.
<?php echo htmlspecialchars($drill['title']); ?>
PlaceholderNo Image

...

1) : ?>