Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class='container_allen result'>
- <div class="panel panel-primary" style="width:1024px; margin:0 auto;">
- <div class="panel-heading"><h5>Result</h5></div>
- <div class="panel-body">
- <?php
- function display_candidate($p){
- if (isset($_POST['year'])) {
- $year = $_POST['year'];
- }
- else{
- $year = date('Y');
- }
- $sql = mysql_query("SELECT * FROM candidates WHERE position = '$p' AND year = $year");
- $count_voters = mysql_query("SELECT count(*) as total_voters FROM voters WHERE done_voting = 1");
- $count_total_voters = mysql_fetch_assoc($count_voters);
- echo " <table>
- <tr>
- <td><h3>" . $p . "</h3></td>
- <td></td>
- </tr>
- ";
- while($row = mysql_fetch_array($sql)){
- $a = md5($row['c_id']);
- $count = mysql_query("SELECT count(*) as total FROM votes WHERE voted_candidate = '$a'");
- $count_result = mysql_fetch_assoc($count);
- $percentage = round($count_result['total'] / $count_total_voters['total_voters'] * 100, 2) . "%";
- echo "<tr>";
- echo "<td width='200px;'>" . $row['firstname'] . " " . $row['lastname'] . "</td>";
- echo "<td><meter style='width:500px;' min='0' max='" . $count_total_voters['total_voters'] . "' value='" . $count_result['total'] . "'></meter></td>";
- echo "<td style='padding-left: 20px;'>" . $count_result['total'] . "</td>";
- echo "<td style='padding-left: 20px;'>" . $percentage . "</td>";
- echo "</tr>";
- }
- echo " </table>";
- }
- $display = mysql_query("SELECT * FROM positions");
- while ($display_row = mysql_fetch_array($display)) {
- display_candidate($display_row['position_name']);
- }
- $count = mysql_query("SELECT * FROM voters WHERE done_voting = '1");
- $result = mysql_num_rows($count);
- echo "The number of student that voted are" .$result ."";
- ?>
- </div>
- </div>
- <br>
- <center>
- <a href="../../ONLINE VIEWING/report.php"><button type="button" class="btn btn-primary">View Report</button></a>
- <a href="winners.php"><button type="button" class="btn btn-success">Post Winners</button></a>
- </center>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement