Jump to content

Help with search query


rondog

Recommended Posts

The search doesn't work on the forum right now and I'm sure this has been brought up many times.

 

so I guess this will work for multiple words.

 

<?php
$arr = explode(' ', $searchtxt);

$query = "SELECT * FROM video WHERE keywords LIKE '%$searchtxt%'";
foreach($arr as $v) {
$query .= " OR keywords LIKE '%$v%'";
}
$result= mysql_query($query);
$totalRows = mysql_num_rows($result);
?>

 

Ok lets use the word "Africa" as an example.

 

If I search "africa" something with africa in the keywords field pops up...if I search "african" nothing comes up. How can I make it so whether I search for "africa" or "african" they both will pop up the results?

Link to comment
https://forums.phpfreaks.com/topic/94531-help-with-search-query/
Share on other sites

Doesn't that mean anything with "a", "can", "ric", "af" etc would also show up?

 

It makes sense that "Africa" would return "Africa" and "African" and not vice versa.  I'm sure there are more searches than just this one word you will be doing right?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.