$sql = mysql_query("select * from tbl_1");
echo '<form method="get" action="" id="form1">';
echo 'Kabupaten:';
echo '<select name="kabupaten" onchange="document.getElementById('form1').submit()">';
echo '<option value="">pilih</option>';
$kabupaten = isset($_GET['kabupaten']) ? $_GET['kabupaten'] : '';
while($kab = mysql_fetch_array($sql)){
echo '<option value="'.$kab['idkab'].'"'.($kabupaten==$kab['idkab'] ? ' selected="selected"' :'').'>'.$kab['namakab'].'</option>';
}
echo '</select>';
echo 'Kecamatan:';
echo '<select name="kecamatan" onchange="document.getElementById('form1').submit()">';
echo '<option value="">pilih</option>';
if(isset($_GET['kabupaten'])){
$sql = mysql_query("select * from tbl_2 where idkab='".$_GET['kabupaten']."'");
$kecamatan = isset($_GET['kecamatan']) ? $_GET['kecamatan'] : '';
while($kec = mysql_fetch_array($sql)){
echo '<option value="'.$kec['idcamat'].'"'.($kecamatan==$kec['idcamat'] ? ' selected="selected"' :'').'>'.$kab['namakecamatan'].'</option>';
}
echo '</select>';
if(isset($_GET['kecamatan'])){
$sql = "select * from tbl_3 where idcamat='".$_GET[kecamatan'']."'";
//tampilkan data
}
echo '</form>';