How to Search item with two or more words or multiple words in php, MYSQL

Key Topics: How to Search item with two or more words or multiple words in php, search one or more words, search multiple words, php, Like, implode, explode, and, or, search words, search string, search keyword, search term, MYSQL, SQL

——————————————————————————————————–

We can use “AND” or “OR” for search one or more words in php.

Example
Test Value:


$searchword = "A Big Dog under the Tree";

$searchkey = explode(' ', $searchword); //Separate search key
$searchkeyterm = array();
foreach ($searchkey as $key) {
     $key = trim($key); // Remove White Spaces
     if (!empty($key)) {
          $searchkeyterm[] = "title LIKE '%$key%'";
     }
}

$query_result = mysql_query("SELECT * FROM tbl_article WHERE " . implode(' AND ', $searchkeyterm));

 
By
Domferdy

——————————————————————————————————–

Key Topics: How to Search item with two or more words or multiple words in php, search one or more words, search multiple words, php, Like, implode, explode, and, or, search words, search string, search keyword, search term, MYSQL, SQL

 

How to Search item with two or more words or multiple words in php, MYSQL angelsujimeena Computers & Internet,,,,,,,,,,,,,,
Key Topics: How to Search item with two or more words or multiple words in php, search one or more words, search multiple words, php, Like, implode, explode, and, or, search words, search string, search keyword, search term, MYSQL, SQL -------------------------------------------------------------------------------------------------------- We can use 'AND' or 'OR' for search one or...
<strong>Key Topics:</strong> How to Search item with two or more words or multiple words in php, search one or more words, search multiple words, php, Like, implode, explode, and, or, search words, search string, search keyword, search term, MYSQL, SQL -------------------------------------------------------------------------------------------------------- We can use "AND" or "OR" for search one or more words in php. <span style="color: #ff6600;"><strong>Example</strong></span> <span style="text-decoration: underline;"><strong> Test Value:</strong></span> <pre><code> $searchword = "A Big Dog under the Tree"; $searchkey = explode(' ', $searchword); //Separate search key $searchkeyterm = array(); foreach ($searchkey as $key) { $key = trim($key); // Remove White Spaces if (!empty($key)) { $searchkeyterm[] = "title LIKE '%$key%'"; } } $query_result = mysql_query("SELECT * FROM tbl_article WHERE " . implode(' AND ', $searchkeyterm)); </code></pre> <address> </address><address>By</address><address>Domferdy</address>-------------------------------------------------------------------------------------------------------- <strong>Key Topics:</strong> How to Search item with two or more words or multiple words in php, search one or more words, search multiple words, php, Like, implode, explode, and, or, search words, search string, search keyword, search term, MYSQL, SQL  

No Responses

This site uses Akismet to reduce spam. Learn how your comment data is processed.