Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Two Problems: % Wildcard & FULL-TEXT Searches

ony results for first column that is searched... & no partial matches

10:15 pm on Jan 23, 2005 (gmt 0)

10+ Year Member

With regards to this SQL statement.... It works great for multi-word searches but those searches have to be spelled correctly.

I have discovered two FLAWS:

1. It does not allow for partial matches: i.e. 'shane' if the search is spelled 'shan' it will not find it. I cannot figure out how to get the '%' Wildcard into this statement so it will work.

2. It will ony show results for the first column the search word(s) are found in.

For example, I type in 'shane' and I will get all listings for 'shane' only from the 'wname' column. The search query stops at the first column 'wname' in the SQL statement below and ignores that 'shane' is also located in several other columns and records.

-------> Begin Code



if(isset($_POST['search']) &&!empty($_POST['search'])) {

mysql_connect() or die ("Problem connecting to Database");

$search = trim($_POST['search']);

$sql= mysql_query("SELECT * FROM directory WHERE MATCH (wname,title,keywords,description,city,country,cat
egory,url) AGAINST ('" . $_POST['search'] . "') ", $db);

<------- End Code

Any ideas?

% WILDCARD: These did not work:

$sql= mysql_query("SELECT * FROM directory WHERE MATCH (wname,title,keywords,description,city,country,cat
egory,url) AGAINST ('" . $_POST['%search%'] . "') ", $db);


('%" . $_POST['search'] . "%')

%('" . $_POST['search'] . "')%

'%'('" . $_POST['search'] . "')'%'


12:44 am on Jan 24, 2005 (gmt 0)

10+ Year Member

I feel like such a geek for solving my own questions but I did find something useful.

I added:

AGAINST ('" . $_POST['search'] . "' IN BOOLEAN MODE)

Now it searches all columns instead of stopping at the first in the FULLTEXT search list.

However, I still need to figure out how to incorporate the % Wildcard into this SQL statement:

$sql= mysql_query("SELECT * FROM directory WHERE MATCH (wname,title,keywords,description,city,country,category,url) AGAINST ('" . $_POST['search'] . "' IN BOOLEAN MODE) ", $db);

Any ideas?



Featured Threads

Hot Threads This Week

Hot Threads This Month