Forum Moderators: coopster

Message Too Old, No Replies

Searching Criteria issue

         

kadnan

9:53 am on May 20, 2003 (gmt 0)

10+ Year Member



Hello
I am trying to write a search enigne script which fetches data from MYSQL with help of keywords entered in text box
suppose a user enters a string

$term=This+IS -Funny+Serious-Article+lecture-to+Search

here + means BOOLEAN AND
and - means NOT

i used explode()to split data wrt to + but in some indicies
its storting data with minus sign like
a/c to above critera
if i use explode("+",$term)
arr[indexValue]=Searious-Article which isn`t required

-can anyone help me in this regard so that i could make a proper SQL query from these keywords?
comverting + into AND and - into NOT is not issue at all,its just i need to find a way to make it inform of SQL query
thanks in advanced
-adnan

daisho

12:38 pm on May 20, 2003 (gmt 0)

10+ Year Member



This is not really answering your question but there is an opensource search engine called mnoGoSearch. It has a PHP (as well as others) frontend.

To answer your questions a forearch loop adding something like the following will do it:

$sql.=" AND dbfield like '%$value%'";

daisho.

BCMG_Scott

2:41 pm on May 20, 2003 (gmt 0)

10+ Year Member



If you are using MySQL 4.0.1 or greater you can use the fulltext search with the boolean mode option. You must create a fulltext index on the field that you wish to search. Then you can issue the following SQL:

SELECT * FROM search_table WHERE MATCH(text) AGAINST ('$term' IN BOOLEAN MODE);

See section 6.8 MySQL Full-text Search in the mysql.com documentation.

Scott Geiger