Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. <div class='container_allen result'>
  2.  
  3. <div class="panel panel-primary" style="width:1024px; margin:0 auto;">
  4.  
  5. <div class="panel-heading"><h5>Result</h5></div>
  6.  
  7. <div class="panel-body">
  8.  
  9. <?php
  10.  
  11. function display_candidate($p){
  12.  
  13. if (isset($_POST['year'])) {
  14. $year = $_POST['year'];
  15. }
  16. else{
  17. $year = date('Y');
  18. }
  19.  
  20. $sql = mysql_query("SELECT * FROM candidates WHERE position = '$p' AND year = $year");
  21. $count_voters = mysql_query("SELECT count(*) as total_voters FROM voters WHERE done_voting = 1");
  22. $count_total_voters = mysql_fetch_assoc($count_voters);
  23.  
  24. echo " <table>
  25. <tr>
  26. <td><h3>" . $p . "</h3></td>
  27. <td></td>
  28. </tr>
  29. ";
  30.  
  31. while($row = mysql_fetch_array($sql)){
  32.  
  33. $a = md5($row['c_id']);
  34.  
  35. $count = mysql_query("SELECT count(*) as total FROM votes WHERE voted_candidate = '$a'");
  36. $count_result = mysql_fetch_assoc($count);
  37.  
  38. $percentage = round($count_result['total'] / $count_total_voters['total_voters'] * 100, 2) . "%";
  39.  
  40. echo "<tr>";
  41. echo "<td width='200px;'>" . $row['firstname'] . " " . $row['lastname'] . "</td>";
  42. echo "<td><meter style='width:500px;' min='0' max='" . $count_total_voters['total_voters'] . "' value='" . $count_result['total'] . "'></meter></td>";
  43. echo "<td style='padding-left: 20px;'>" . $count_result['total'] . "</td>";
  44. echo "<td style='padding-left: 20px;'>" . $percentage . "</td>";
  45. echo "</tr>";
  46.  
  47. }
  48.  
  49. echo " </table>";
  50.  
  51. }
  52.  
  53. $display = mysql_query("SELECT * FROM positions");
  54.  
  55. while ($display_row = mysql_fetch_array($display)) {
  56.  
  57. display_candidate($display_row['position_name']);
  58.  
  59. }
  60. $count = mysql_query("SELECT * FROM voters WHERE done_voting = '1");
  61. $result = mysql_num_rows($count);
  62. echo "The number of student that voted are" .$result ."";
  63. ?>
  64.  
  65. </div>
  66.  
  67. </div>
  68. <br>
  69. <center>
  70. <a href="../../ONLINE VIEWING/report.php"><button type="button" class="btn btn-primary">View Report</button></a>
  71. <a href="winners.php"><button type="button" class="btn btn-success">Post Winners</button></a>
  72. </center>
  73.  
  74. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement