Last active
March 17, 2019 09:24
-
-
Save eftalyurtseven/4408277 to your computer and use it in GitHub Desktop.
jQuery Php Anında Arama
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | |
<title>Eftal Yurtseven Anında Arama</title> | |
<link rel="stylesheet" href="style.css"/> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script> | |
<script type="text/javascript"> | |
$(function(){ | |
$("#sonuclar").hide(); | |
// Tıklandığında işlem yap | |
$(".input").keyup(function(){ | |
// Veriyi alalım | |
var value = $(this).val(); | |
var deger = "value="+value; | |
$.ajax({ | |
type: "POST", | |
url: "post.php", | |
data: deger, | |
success: function(cevap){ | |
if(cevap == "yok"){ | |
$("#sonuclar").show().html(""); | |
$("#sonuclar").html("Hiç bir sonuç bulunamadı!!"); | |
}else if(cevap == "bos"){ | |
$("#sonuclar").hide(); | |
}else { | |
$("#sonuclar").show(); | |
$("#sonuclar").html(cevap); | |
} | |
} | |
}) | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<!-- Ortala --> | |
<div id="ortala"> | |
<input type="text" name="eftal" class="input"/> | |
<div id="sonuclar"><ul></ul></div> | |
</div> | |
<!--#Ortala --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if($_POST){ | |
/* | |
* Mysql Connect | |
*/ | |
$connx = mysql_connect("localhost","root") or die(mysql_error()); | |
$dbConnx = mysql_select_db("test", $connx) or die(mysql_error()); | |
/* ---------------- **/ | |
/* | |
* Veriyi Alalım ve işlemleri yapalım | |
*/ | |
$value = mysql_real_escape_string(strip_tags(rtrim($_POST['value']))); | |
if(!$value){ | |
echo 'bos'; | |
}else{ | |
$find = mysql_query("SELECT * FROM deger WHERE deger like '$value%'"); | |
if(mysql_affected_rows()){ | |
while($row = mysql_fetch_assoc($find)){ | |
echo '<li>'.$row["deger"].'</li>'; | |
} | |
}else{ | |
echo 'yok'; | |
} | |
} | |
}else{ | |
header("Location: index.php"); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Eftal Yurtseven */ | |
body{margin: 0; padding: 0; background: #fff} | |
*{margin: 0; padding: 0; list-style-type: none; border: none} | |
#ortala{width: 550px; padding: 10px; margin: 70px auto; background: #f1f1f1; border: 2px solid #ddd} | |
.input{padding: 7px; width: 400px; margin-left: 80px; background: #fff; border: 1px solid #eee; font: 12px Tahoma} | |
#sonuclar{width: 400px; padding: 7px; margin-left: 80px; margin-top: 10px; background: #fff; border: 1px solid #eee; font: 12px Tahoma} | |
#sonuclar li{border-bottom: 1px solid #eee; padding: 5px; margin-bottom: 5px} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Merhaba, emeğinize sağlık. Her tuş basımında bir önceki aktif (varsa) olan ajax talebini iptal eden bir metod göremedim.