Quick Search:
 PHP Code: Search All Words Of A String In mySQL Jump to:  
Category: >> PHP Code >> Search All Words Of A String In mySQL  

<< lastnext >>

Snippet Name: Search All Words Of A String In mySQL

Description: This code will break a string of words up along the spaces and do a mySQL search for each of the words in the string.

Also see:
» Search and Replace On Every Field In E...
» Neatly trim a string to a set number o...
» Search array elements for a substring
» Add a period at the end of a string if...
» Count capital letters in a string
» Search All Words Of A String In mySQL
» Remove Extra Spaces From A String
» Get Query String with Javascript
» Create string by formatting an amount ...
» Search PL/SQL for a string/ key value
» INSTR (InString)
» SUBSTR (SubString)
» Generate unique strings of random numb...
» String Functions: REVERSE
» String Functions: LENGTH
» String Functions: INSTR
» String Functions: CONCAT
» String Functions: CHAR
» String Functions: INITCAP
» String Functions: LOWER
» String Functions: UPPER
» Sort comma separated string
» String to Date
» Generate random string
» De-Pluralize a String
» Add string to field
» Column copy with string replacement
» Extract part of a string
» Finding a substring in a string
» Make comma-separated list of strings

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

$string = "A sample string with several words";
$words = EXPLODE(" ",$string);
FOR($i=0;$i<count($words);$i++){$query_string .= "LIKE '%".$words[$i]."%' OR ";}
$query_string = SUBSTR($query_string,0,STRLEN($query_string)-4);
$sql = "SELECT * FROM test WHERE title ".$query_string." ORDER BY id DESC";

   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org