untuk get nya
<?php
$con = mysql_connect("localhost","root","");
mysql_select_db('db_umroh');
$user=$_SESSION['login_user'];
$key=substr($user,-4);
$sql = "SELECT * FROM tabel_cabang WHERE id_cabang like '$key%'";
$json = array();
$query = mysql_query($sql);
while($data = mysql_fetch_array($query)){
//sesuaikan dengan struktur tabelmu
$json[] = array(
'label' => $data['id_cabang'],
'value' => $data['id_cabang'],
'nama' => $data['kota_cabang']
);
}
header("Content-Type: application/json");
echo json_encode($json);
?>
untuk nampilinnya
<script type="text/javascript">
//tambahkan auto complete
$('#id_cabang').autocomplete({
source: "get_data.php",
minLength: 40,
select: function( event, ui ) {
$('#txtNm').val(ui.item.nama);
}
});
});
</script>
<tr>
<td height="36">Cabang Kota</td>
<td><input name="txtNm" type="text" id="txtNm" /></td>
</tr>
Masalahnya gak muncul2 itu knp yah gan
..mohon bantuannya