query("SELECT COUNT(*) FROM poll_votes")->fetchColumn(); // Display the results foreach ($options as $id => $option) { // Get the vote count for this option $vote_count = $db->query("SELECT COUNT(*) FROM poll_votes WHERE option_id=$id")->fetchColumn(); // Calculate the percentage of votes for this option $percentage = round(($vote_count / $total_votes) * 100); // Display the results echo "$option: $percentage% ($vote_count votes)
"; } ?>