PHP: How to use mysql fulltext search and handle fulltext search result

Posted by garcon1986 on Stack Overflow See other posts from Stack Overflow or by garcon1986
Published on 2010-03-08T10:43:37Z Indexed on 2010/03/08 10:51 UTC
Read the original article Hit count: 370

Filed under:
|
|
|

Hello,

I have tried to use mysql fulltext search in my intranet. I wanted to use it to search in multiple tables, and get the independant results depending on tables in the result page.

This is what i did for searching.

$query = "
        SELECT *
        FROM testtable t1, testtable2 t2, testtable3 t3
        WHERE match(t1.firstName, t1.lastName, t1.details) against(' ".$value."')
        or match(t2.others, t2.information, t2.details) against(' ".$value."')
        or match(t3.other, t2.info, t2.details) against(' ".$value."')
        ";

$result = mysql_query($query)or die('query error'.mysql_error());

while($row = mysql_fetch_assoc($result)){
    echo $row['firstName'];
    echo $row['lastName'];
    echo $row['details'].'<br />';
}

Do you have any ideas about optimizing the query and format the output of search results?

© Stack Overflow or respective owner

Related posts about php

Related posts about fulltext-search