
<link rel="stylesheet" href="jqm/jquery.mobile-1.3.2.min.css" />
<script src="jquery-1.9.1.min.js"></script>
<script src="jqm/jquery.mobile-1.3.2.min.js"></script>


	
    <div data-role="collapsible-set" data-content-theme="d" id="set">
<?php
	$qry=mysqli_query($mysqli, "SELECT * FROM m_kecamatan ORDER BY nama_kecamatan ASC");
	
	if(mysqli_num_rows($qry)>0){
		while($data=mysqli_fetch_array($qry)){
			echo "<div data-role=\"collapsible\" id=\"set1\" data-collapsed=\"true\">";
			echo "<h3>$data[nama_kecamatan]</h3>";
			echo "<table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
			
			echo "    <tr>
							<th align='left' valign='top' width='20%'>Nama Desa</th>
							
							<th align='left' valign='top' width='75%'>Grafik</th>
					  </tr>";
			$qr=mysqli_query($mysqli, "SELECT * FROM m_desa WHERE id_kecamatan='$data[id_kecamatan]'");
			while($dt=mysqli_fetch_array($qr)){
				$qd=mysqli_query($mysqli, "SELECT * FROM m_user WHERE id_desa='$dt[id_desa]'");
				$dtd=mysqli_fetch_array($qd);
				$id_tpk=$dtd["id"];
				
				//menghitung total rows tabel logs
				$qrk=mysqli_query($mysqli, "SELECT * FROM logs");
				$jum_rows = mysqli_num_rows($qrk);
				
				//menghitung aktivitas per TPK
				$qrk=mysqli_query($mysqli, "SELECT * FROM logs WHERE id_tpk='$id_tpk'");
				$jum_aktivitas = mysqli_num_rows($qrk);
				
				//menghitung prosentase
				$prosentase=intval(($jum_aktivitas / $jum_rows) * 100);
				
				echo "<tr>
							<td align='left' valign='top'>$dt[nama_desa]</td>
							
							<td align='left' valign='top'>";
							for($i=1;$i<=$prosentase;$i++){
								echo "<img src='images/bars.jpg' title='$prosentase %'/>";
							}
							
				echo  "		</td>
					  </tr>";
			}
			echo "</table>";
			echo "</div>";
		}	
	}else{
		echo "<h3>Tidak ada data lowongan pekerjaan...</h3>";
	}
	
?>
</div>