Hello,
I have 5 tables in a MySql database that i wish to do a freetext text search on. The thing is it only seems to work on one table, but all the tables are identical apart from the content.
There are no errors, it just isn't producing any returned rows. Even though i know the words exist in the table data.
Here is what i have done:
To create FULLTEXT on all the tables i did this for each table
ALTER TABLE tableName ADD FULLTEXT(title, copy)
Then i use this to search the tables one at a time
function searchTables($searchTerm)
{
print "<ul class='links'>";
searchTablesSql('directory',$searchTerm);
searchTablesSql('features',$searchTerm);
searchTablesSql('news',$searchTerm);
searchTablesSql('offers',$searchTerm);
searchTablesSql('products',$searchTerm);
searchTablesSql('recipes',$searchTerm);
searchTablesSql('restaurants',$searchTerm);
print "</ul>";
}
function searchTablesSql($tableName,$searchTerm)
{
$sql_build = "SELECT * FROM `$tableName` WHERE MATCH(title,copy) AGAINST('$searchTerm,$searchTerm') ";
$result_build = mysql_query($sql_build);
while ($row=mysql_fetch_assoc($result_build)) {
print "<li><a href='directory.php' title='TITLE HERE'>$row[title]</a></li>";
}
}
Like i said it works fine for the first table (directory), but none of the others??