php - Like function results error -


i have written code users searches in webpage. here sample code going wrong.

$first = true;  foreach ($terms $each)  {     if ($first) {         $query .= "keywords '%$each%' ";         $first = false;     }     else {         $query .= "or keywords '%$each%' ";     }  } 

here example fails: when user enters "best o" should display words contains "%best% %o%" in single word going display results contains 2 words there space entered user in between best , o.

it's not searching them in single word. it's searching "best" once , "o" once in words.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -