0

I use JQuery auto-complete, and it works fine, my question is;

Lets say that the phrase is "Lenovo Y550 Notebook", and auto-complete is OK when I write "Lenovo Y550" or "Y550 Notebook" but I get no auto-complete when I write "Lenovo Notebook".

Is there someway that JQuery could skip some words, check words in all phrases and not just next one? Can that be done in JQuery auto-complete?

EDIT:

auto_complete.php

<?php

/ MYSQL Connection data /

$q =  strtolower($_GET["q"]);
if (!$q) return;

$sql = "SELECT DISTINCT name AS name 
FROM products_names A JOIN products B ON A.id_product = B.id 
WHERE ((name LIKE '%$q%' AND language_code = 'pl') OR (name2 LIKE '%$q%' AND language_code = 'pl')) AND status = 0

";

$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) {
    $cname = html_entity_decode($rs['name']);
    echo "$cname\n";
}

?>

Template file:

<script type="text/javascript">
$().ready(function() {
    $("#autosearch").autocomplete("auto_complete.php", {
        width: 352,
        max: 15,
        minChars: 2,
        cacheLength: 10,
        matchContains: true,
        selectFirst: false,
        scroll: false,
        autofill: true
    }).keydown(function(e){
    if (e.keyCode === 13) {
        $(this).closest('form').trigger('submit');
    }
});

});
</script>


<input id="autosearch" type="text" name="query" value="{$smarty.get.query}" class="search-input" />

This code works fine but I would like to check every single word in whole name, not just words next to each other.

Odin
  • 157
  • 2
  • 3
  • 14

0 Answers0