Ask a question about PHP search
For example, I enter the keyword "sincerity" can be "I really have to give you the heart" This sentence to search out, how to use PHP implementation? Please solve the master solution.
------Solution--------------------
References:
Quote: References:
$ar = Preg_split ("//u", ' sincerity ',-1, preg_split_no_empty);
$where =array ();
foreach ($ar as $v)
$where []=] field like '% $v% ' ";
$sql = "SELECT * from TT";
$sql. = Empty ($where)? ': ' where '. Join (' and ', $where);
Echo $sql;
Is this going to search all the fields with "real" and search all the fields with "heart"?
In fact, my result is: If this field contains only a "true" word, this field will not be searched, such as: "I really like" this will not be searched out, or "I am in a good mood" this will not be searched out.
Instead, the fields that include "sincerity" or "true" and "heart" are searched.
For example: I like it honestly. This sentence will be searched out. Or "I really have to give you the heart" This sentence will also be searched out.
This is used in the Office Supplies Sales website Search products, now encountered this problem.
landlord Why not try first?