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();
?>
= htmlspecialchars($election['title']) ?>
GENERATE RESULTS
= htmlspecialchars($election['status']) ?>
Total Voters
= number_format($totalVoters) ?>
Election Period
= date('M d, Y', strtotime($election['start_date_and_time'])) ?> to
= date('M d, Y', strtotime($election['end_date_and_time'])) ?>
Candidate Results
| Candidate Name | Position | Party | Votes |
|---|---|---|---|
| No candidate results available for this election. | |||
| = htmlspecialchars($cand['candidate_name']) ?> | = htmlspecialchars($cand['position_name']) ?> | = htmlspecialchars($cand['party_name'] ?? 'Independent') ?> | = number_format($cand['vote_count']) ?> |