Re: [PHP] Creating a Search field

From: John Taylor-Johnston (taylorjo_at_collegesherbrooke.qc.ca)
Date: 10/10/03


To: php-general@lists.php.net
Date: Fri, 10 Oct 2003 01:41:33 -0400

Don't forget the "in boolean mode" part. It will work a lot better:

SELECT * FROM $table WHERE MATCH (field1,field2,field3,field4) AGAINST ('red lion' IN BOOLEAN MODE);

http://www.mysql.com/doc/en/Fulltext_Search.html

Need more code? let me know. I've fallen in love with what in boolean mode has done for our search engine. I just wish RedHat and MySQL would get together to upgrade the rpms. MySQL 4 has been out for a long time, but only a very early version of MySQL 4.0.?? is available, unless you know lots about re-installing everything to get everything else to work. All it takes is one little old rpm to set things straight. Apprently there is some stupd licencing thing going on.

John

"Larry E . Ullman" wrote:

> > I need to create a feature that allows users to enter certain words
> > that can
> > be searched ie
> > search = 'red lion'
> > this would return all data found with the words red and lion.
>
> If you're using MySQL 4.0, you can take advantage of its FULL TEXT
> searching (it's actually available in earlier versions but much better
> in MySQL 4). See the MySQL manual for more information.
>
> Otherwise, you'll need to parse the search box data to break it up into
> individual words, then create a query like...
>
> WHERE column LIKE '%$var1%' AND column LIKE '%var2%%'...
>
> This will be slow, so make sure your database uses indexes.
>
> Again, see the MySQL manual for more.
>
> Larry

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not open-source, it's Murphy's Law."
  ' ' '   Collège de Sherbrooke:
 ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
   -     Université de Sherbrooke:
          http://compcanlit.ca/
          819-569-2064


Relevant Pages

  • Re: Missing System Tray Items in Xp
    ... John wrote: ... In searching the net I find that this problem seems to have been around ... a long time and everybody seems to have their own pet fix for it, ...
    (microsoft.public.windowsxp.general)
  • Re: counting question
    ... > david 1 ... or even the correct phrase to use when searching for it would help ...
    (microsoft.public.inetserver.asp.general)
  • Re: Missing System Tray Items in Xp
    ... and we will see if the systray icons disappear again. ... Thanks again, John ... Check "My Network Places" and on the left hand side under ... In searching the net I find that this problem seems to have been around ...
    (microsoft.public.windowsxp.general)
  • Re: counting question
    ... select personname, countfrom yourtable group by personname ... > i think you can see why i am having a problem searching for this... ...
    (microsoft.public.inetserver.asp.general)
  • Re: Save area types
    ... McKown, John wrote: ... [Must be searching ... For IBM-MAIN subscribe / signoff / archive access instructions, ...
    (bit.listserv.ibm-main)