query("SELECT * FROM elections WHERE archived = FALSE ORDER BY start_date_and_time DESC")->fetchAll(); // Extract years for the "Jump to School Year" dropdown $years = []; foreach ($elections as $e) { $year = date('Y', strtotime($e['start_date_and_time'])); $years[$year] = $year; } krsort($years); $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Online Election System for Senior High School'; ?> Election History | <?= htmlspecialchars($projectDescription) ?>

Election History

Voter turnout and candidate results per election year

prepare("SELECT COUNT(DISTINCT voter_id) FROM votes WHERE election_id = ?"); $voterCount->execute([$election['id']]); $totalVoters = $voterCount->fetchColumn(); $results = $pdo->prepare(" SELECT c.*, u.name as candidate_name, p.name as position_name, (SELECT COUNT(*) FROM votes v WHERE v.candidate_id = c.id) as vote_count FROM candidates c JOIN users u ON c.user_id = u.id JOIN positions p ON c.position_id = p.id WHERE c.election_id = ? ORDER BY p.sort_order, vote_count DESC "); $results->execute([$election['id']]); $candidates = $results->fetchAll(); ?>
Total Voters
Election Period
to
Candidate Results
Candidate Name Position Party Votes
No candidate results available for this election.