简体   繁体   中英

Search Page with Ajax (algorithm)

I want to make a search page like google that when i input 'ex' then with the ajax we recognition that the user intend to input 'example' or 'exam' or ... what is the algorithm for making a page like this ? is the query of mysql like : "SELECT * FROM users WHERE upper($field) LIKE'%$find%'" ? Thanks in Advance .

the query is almost this
mysql_query("select * from users where queryfield like '$q%' order by queryfield");
you may use jquery autocomplete to ease your work

<input type="text" id="populate">
<script type="text/javascript">

   $(function() {

    $("#populate").autocomplete({
        url: 'search.php',
        cache: false,
        onItemSelect: function(item) {
            window.location.href=item.data;
            document.getElementById('populate').value='';

        },
    });

});


    </script>


for complete source:
http://jqueryui.com/demos/autocomplete/#remote

I think it works like this, suppose we have two tables, one are the articles / links in demand, others are the key words 'search engine breaks', but what good these keywords? to me, is a popularity index, because it is the most sought after, this index is based on that ..

The more a person searches, eg ' i an legend ' or ' legend an i ', ' movie legend ', ' god is legend ' .. the word 'legend' was searched four times, and its index will be built based on this, but .. you have a limit order, they may have many words that have been sought, but did not even enter the search or in addition

You will have to do something like this, create a table, where it will update every 25% of searches, the words .. when the user is typing, you show the suggestions.

You should do something, it would bring better results for those who use the search, however, you can resolve the suggest problem with jQuery Autocomplete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM