I need to arrange instant search for my website (like google instant). When the user is typing, the script should suggest results. As I understood I need php+html+javascript. Any suggestions, or link or something helpfull?
thanks in advance
You should set tags for each article, or ex. search in every category on your site.
Example code for the front-end:
// index.html
// ajax
<script type="text/javascript">
function loadXML(query) {
$.ajax({
type: "POST",
data: ({ajaxSearch : query.value}),
url: 'search.php',
success: function(data) {
$('#searchcontainer').html(data);
}
});
</script>
// html
<input type="text" id="ajaxSearch" onkeyup="loadXML(this);" />
<div id="searchcontainer"></div>
In order to do that you need crazy amount of indexing. You need to index almost every keyword and store search results for each keyword. There is no way you can do a live search on database that fast. Once you have good index you can use .keypress function of JQuery to detect if user is typing something, once user types something you can send the search query to the server and fetch the result and display using javascript.
Try it with jQuery UI Autocomplete. It's easy to setup and fairly easy to implement what you're after:
http://jqueryui.com/demos/autocomplete/
The data for the search will be in an array of strings, like
so you'll need to do a database query (or setup manual search terms) and populate your array based on that.