PHP + MySQL Recursive Word Search
September 8th, 2006 Posted in MYSQL, PHPThis script will allow you totype asmany words as you like into a text box and find instances where all of these words exists in any field. The words entered only need to be seperated by spaces, no commas required!
PHP:
-
for($x=0;$x<$count;$x++){
-
if($repeat == 0){
-
$sqlquery .= " WHERE (keyword1 LIKE '%".$search[$x]."%' OR keyword2 LIKE '%".$search[$x]."%' OR caption LIKE '%".$search[$x]."%')";
-
$repeat = 1;
-
}else{
-
$sqlquery .= " AND (keyword1 LIKE '%".$search[$x]."%' OR keyword2 LIKE '%".$search[$x]."%' OR caption LIKE '%".$search[$x]."%')";
-
}
-
}