query('SELECT id, title, category, book_ref, chapter_ref, summary FROM events ORDER BY sort_order')->fetchAll(PDO::FETCH_ASSOC); // Load single event if needed $event = null; $questions = []; if ($eventId > 0 && in_array($view, ['read','quiz'])) { $stmt = $db->prepare('SELECT * FROM events WHERE id = ?'); $stmt->execute([$eventId]); $event = $stmt->fetch(PDO::FETCH_ASSOC); if (!$event) { $eventId = 0; $view = 'list'; } if ($view === 'quiz') { $stmt = $db->prepare('SELECT * FROM quiz_questions WHERE entity_type = ? AND entity_id = ? ORDER BY sort_order'); $stmt->execute(['event', $eventId]); $questions = $stmt->fetchAll(PDO::FETCH_ASSOC); } } // Best quiz result for this event $bestScore = null; if ($eventId > 0) { $stmt = $db->prepare('SELECT score, total FROM quiz_results WHERE user_id = ? AND entity_type = ? AND entity_id = ? ORDER BY score DESC LIMIT 1'); $stmt->execute([$userId, 'event', $eventId]); $bestScore = $stmt->fetch(PDO::FETCH_ASSOC); } // Best scores for list view $myBest = []; $stmt = $db->prepare('SELECT entity_id, MAX(score) as best_score, MAX(total) as total FROM quiz_results WHERE user_id = ? AND entity_type = ? GROUP BY entity_id'); $stmt->execute([$userId, 'event']); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $myBest[$row['entity_id']] = $row; } ?>

Significant Events

Explore the defining moments of the New Testament — read each account in depth, then test your knowledge with a quiz.

= 80) $badgeClass = 'badge-gold'; elseif ($pct >= 60) $badgeClass = 'badge-silver'; else $badgeClass = 'badge-bronze'; } ?>
%
New

← All Events /