<?php
	/*
	$qry0=mysqli_query($mysqli,"SELECT * FROM t_anggaran WHERE LENGTH(kode_rekening)=1 ORDER BY kode_rekening ASC");
	echo "<select>";
	while($kol0=mysqli_fetch_array($qry0)){
		
		echo "<optgroup label='$kol0[kode_rekening] - $kol0[uraian]'>";
		$qryx1=mysqli_query($mysqli,"SELECT * FROM t_anggaran WHERE LENGTH(kode_rekening)=2 AND jenis_kode_rekening='H' AND induk_kode_rekening='$kol0[kode_rekening]' ORDER BY kode_rekening ASC");
		while($kol1=mysqli_fetch_array($qryx1)){
			echo "<optgroup label='&nbsp;&nbsp;$kol1[kode_rekening] - $kol1[uraian]'>";
			$qryx2=mysqli_query($mysqli,"SELECT * FROM t_anggaran WHERE LENGTH(kode_rekening)=3 AND jenis_kode_rekening='H' AND induk_kode_rekening='$kol1[kode_rekening]' ORDER BY kode_rekening ASC");
			while($kol2=mysqli_fetch_array($qryx2)){
				echo "<optgroup label='&nbsp;&nbsp;&nbsp;&nbsp;$kol2[kode_rekening] - $kol2[uraian]'>";
				$qryx3=mysqli_query($mysqli,"SELECT * FROM t_anggaran WHERE LENGTH(kode_rekening)=4 AND jenis_kode_rekening='H' AND induk_kode_rekening='$kol2[kode_rekening]' ORDER BY kode_rekening ASC");
				while($kol3=mysqli_fetch_array($qryx3)){
					echo "<optgroup label='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$kol3[kode_rekening] - $kol3[uraian]'>";
					$qryx4=mysqli_query($mysqli,"SELECT * FROM t_anggaran WHERE LENGTH(kode_rekening)=4 AND jenis_kode_rekening='D' AND LEFT(kode_rekening,4)='$kol3[kode_rekening]' ORDER BY kode_rekening ASC");
					while($kol4=mysqli_fetch_array($qryx4)){
						echo "<option value=''>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$kol4[kode_rekening] - $kol4[uraian]</option>";
					}

					echo "</optgroup>";
				}

				echo "</optgroup>";
			}

			echo "</optgroup>";
		}
		echo "</optgroup>";

		
	}
	echo "</select>";
	*/
	
	$qry=mysqli_query($mysqli,"SELECT * FROM m_kecamatan ORDER BY nama_kecamatan ASC");

	echo "<h3 align=\"right\" style=\"padding-right:10px\"><a href='?action=add_kecamatan' style=\"color:#FF0066\">Tambah Data Kecamatan</a></h3>";
	
	if(mysqli_num_rows($qry)>0){
		
		$no=1;
		
		echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
		echo "<tr bgcolor='#fffccc'>
				<th width='5%'>No.</th>
				<th>Kecamatan</th>
				<th width='10%'>Opsi</th>
			  </tr>";	
		while($data=mysqli_fetch_array($qry)){
			echo "<tr bgcolor=\"#fffcfc\">
					<td align=\"center\">$no</td>
					<td>$data[nama_kecamatan]</td>
					<td align=\"center\"><a href=\"?action=edit_kecamatan&id_kecamatan=$data[id_kecamatan]\"><img src=\"images/edit.gif\" /></a>&nbsp;|&nbsp;<a href=\"_del_kecamatan.php?id_kecamatan=$data[id_kecamatan]\" onclick=\"return confirm('Yakin akan menghapus data Kecamatan $data[nama_kecamatan] ?')\"><img src=\"images/delete.gif\" /></a></td>
					
			     </tr>";
			$no++;  
		}
		
		echo "</table>";
	}else{
	
		echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
		echo "<tr bgcolor='#fffccc'>
				<th>No.</th>
				<th>Kecamatan</th>
				<th>Opsi</th>
			  </tr>";
		
		echo "<tr>
					<td colspan='3' align='center'>Tidak ditemukan data Kecamatan</td>
			     </tr>";		
		echo "</table>";
	}
?>