<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css"/>

  <title>KVS Digital - VOTING SYSTEM</title>
</head>
<body>
   <div class="container">
 <div class="container">
    <nav class="navbar navbar-default">

     <h1>KVS Digital - VOTING SYSTEM</h1>
    <ul class="nav navbar-nav">
      <li class="active"><a href="index.html">Home</a></li>
      <li><a href="login.html">Undian</a></li>
      <li><a href="admin.html">Admin</a></li>
    </ul>

  </nav>
<?php
      

 include 'dbconn.php';

//counting total vote

$sql = "SELECT * FROM tblcandidate ORDER BY voteCount+0 DESC";
$result = mysqli_query($conn, $sql);

//$sql1 = "SELECT * FROM tblcandidate WHERE candPOST = 'SIJIL' ORDER BY voteCount DESC";
//$result1 = mysqli_query($conn, $sql1);
 
?>
</div>
<div class="container">

<table class="table table-striped">
<thead>KEPUTUSAN PEMILIHAN MAJLIS PERWAKILAN PELAJAR KOLEJ VOKASIONAL SEPANG - EXCO DVM</thead>
<tbody>
  <tr>
    <th>No</th>
    <th>ID Calon</th>
    <th>Nama</th>
    <th>Kelas</th>
    <th>Bilangan Undian</th>
  </tr>

</tbody>
<?php
$num = 0;
$totalVotes=0;
while($row = mysqli_fetch_assoc($result)) {
$totalVotes = $totalVotes + $row[voteCount];
$num = $num +1;
?>

<tr>
    <td><?php echo "$num";?></td>
  <td><?php echo "$row[candIC]";?></td>
  <td><?php echo "$row[candName]";?></td>
  <td><?php echo "$row[candCourse]";?></td>
  <td><?php echo "$row[voteCount]";}?></td>
</tr>
</table>
<p>Jumlah Undian : <?php echo $totalVotes;?></p>

</div>
<br>
<div class="container">
<p id="footer"></p>
<table class="table table-striped">
<!--<thead>KEPUTUSAN PEMILIHAN MAJLIS PERWAKILAN PELAJAR KOLEJ VOKASIONAL SEPANG - EXCO SVM</thead>
<tbody>
  <tr>
    <th>ID Calon</th>
    <th>Nama</th>
    <th>Kelas</th>
    <th>Bilangan Undian</th>
  </tr>

</tbody>-->
<?php
/*$totalVotes1=0;
while($row1 = mysqli_fetch_assoc($result1)) {
$totalVotes1 = $totalVotes1 + $row1[voteCount];
*/
?>

<!--<tr>
  <td><?php //echo "$row1[candIC]";?></td>
  <td><?php //echo "$row1[candName]";?></td>
  <td><?php //echo "$row1[candCourse]";?></td>
  <td><?php //echo "$row1[voteCount]";}?></td>
</tr>
</table>-->


<button onclick="myFunction()">Print this page</button>

<script>
function myFunction() {
    
    document.getElementById("footer").style.pageBreakAfter = "always";
    window.print();
    
}
</script>

</div>
</body>
</html>
