PDA

View Full Version : SQL Match Against not working



Icy Penguin
July 3rd, 2008, 01:58 PM
$books_sql .= "SELECT *, MATCH (title) AGAINST ('$keywords') AS score FROM books WHERE MATCH (title) AGAINST ('$keywords') ORDER BY SCORE desc";

Right now I just have two rows in my table - one of which whose title is "some boring book".

When I set $keywords to 'some' or 'boring', for example, I get no rows returned. Do I need to put in more rows if I want to test out my search function?

stiffi
July 3rd, 2008, 06:20 PM
although im in no way an expert but i would try something like this




$var = @$_GET['query'] ; //or whatever you have named it in your search form
$trimmed = trim($var);
$query = "select * from table where 1_field like \"%$trimmed%\"
order by 1_field";

Icy Penguin
July 3rd, 2008, 08:05 PM
That's what I had before - but I realized after doing some research that this is the old and ugly way to do it - and fulltext is the way to go now.

Thanks