PHP AutoComplete.
arkadaşlar php ve jquery kullanarak autocomplete yapmaya çalıştım bu konuda daha acemiyim hatam nerede yardımcı olursanız sevinirim, şimdiden teşekkürler.
ekranda gözüken kısım burası
test1.php
<!doctype html>
<html lang="us">
<head>
<meta charset="utf-8">
<title>Başlıksız Belge</title>
<link href="css/base/jquery-ui-1.9.2.custom.css" rel="stylesheet nofollow">
<script src="js/jquery-1.8.3.js"></script>
<script src="js/jquery-ui-1.9.2.custom.js"></script>
</head>
<script>
$(function() {
$("#autocomplete").autocomplete({
source: "test2.php",
minLength: 2
});
});
</script>
<form>
<input type="text" id="autocomplete" name="autocomplete"/>
</form>
<body>
veri tabanından veri çektiğim kısımda burası
test2.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Başlıksız Belge</title>
</head>
<body>
<?php
include("baglanti.php");
$arama = $_REQUEST['autocomplete'];
$sorgu= mysql_query("SELECT * FROM kullanicilar WHERE kullaniciadi LIKE '%{$arama}%'");
$UyeListesi = array();
while($sonuc=mysql_fetch_array($sorgu))
{
$UyeListesi[] = $sonuc['kullaniciadi'];
}
echo json_encode($UyeListesi);
?>
</body>
</html>
Php
test2.php Eğer JSON üretiyorsa içinde <!doctype html><html> falan olmamalı. UTF kodlanmış boş sayfa olmalı.