php - Search with split text in DB and get re-hitting value -


i'd matched data db split array in search query.
imagine query is: "how buy motorbike" & in db i've enlisted data

  1. buy helicopter

  2. buy motorbike

  3. buy car

so, after split query, it'll search db "how", "to","buy", "motorbike" respectfully. using these sub-strings, query generate "buy helicopter" string in output. want buy motorbike data. generated method encode data when of these sub-strings matched same data in db. here's code fetch first matched data desired data in no. 2.

$str=$_post['search'];  $str=preg_split("/[\s]+/",  $str); foreach ($str $search ) { $sql = "select answer query_tbl q1  '%".$search."%' "; $record = mysqli_query($link, $sql); $rows=mysqli_fetch_assoc($record);   if ($rows == true) {      echo  json_encode(array('ans'=>$rows['answer']));     }  } 

so, algorithm should follow , use achieve goal?

i think best full-text search described here.

by default or in natural language mode modifier, match() function performs natural language search string against text collection. collection set of 1 or more columns included in fulltext index. search string given argument against(). each row in table, match() returns relevance value; is, similarity measure between search string , text in row in columns named in match() list.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -