开发者

Need help on modification to mySQL MATCH AGAINST query

I have a simple jQuery/PHP autocomplete text box that gets the matches from mySQL. In my case if a name in the DB is

Brand new iPhone and iPod case

and the $q is

iph

the textbox will not pop out the above product name for me to select it until I write the entire matching word.

With wildcards 开发者_开发知识库I get my expected result, but when $q is

iphone ipod

I will not get the above product name.

$q = $_GET["q"];
WHERE name LIKE '%$q%'

What I have now is this below and my question is if there is a way to have the result before write the full word AND also to support the iphone ipod issue.

$q = $_GET["q"];
$words = explode(" ", $q);
$all = mysql_real_escape_string(implode(" +",$words));
WHERE MATCH (name) AGAINST ('+" . $all . "' IN BOOLEAN MODE)


$all = mysql_real_escape_string(implode("* +",$words));


WHERE MATCH (name) AGAINST ('+" . $all . "*' IN BOOLEAN MODE)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜