<?php
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");
?>	    
				  <div class='row'>
			             <?php
							$sql="SELECT * FROM kandidat ORDER BY nomor";
                             $query=mysqli_query($koneksi,$sql);
                              $sqljs="SELECT sum(suara) as jsuara FROM kandidat";
                               $queryjs=mysqli_query($koneksi,$sqljs);
                                $rjs=mysqli_fetch_array($queryjs);
                                 while($r=mysqli_fetch_array($query)){
								$siswa=fetch($koneksi,'siswa',['id_siswa'=>$r['idsiswa']]);
                            ?>
                            <div class="col-xl-4">
                                <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">KANDIDAT <?= $r['nomor'] ?></span>
                                                <span class="widget-stats-amount"><?= $siswa['nama'] ?></span>
                                               <span><h3 style="color:blue"><b><?= $r['suara'] ?></b> Suara 
											   <?php if($r['suara']>=1){ ?>
											   <?= ($r['suara']/$rjs['jsuara'])*100 ?> %<?php } ?></h3></span>
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-users-cog"></i> 
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
							 <?php } ?>	 