Ask a question about PHP search

Source: Internet
Author: User
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?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.