This works for the loop.  now spliting up the words.  now it searchs for
just one word in the loop

any suggestions on this


----- Original Message -----
From: "Jason Wong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 14, 2002 9:51 PM
Subject: Re: [PHP] searching key words from a database field


> On Thursday 14 February 2002 16:38, Philip J. Newman wrote:
> > I'm trying to make a search engine for my database of links.  I have
been
> > using the following.
> >
> > SELECT * FROM `hyperlinks` WHERE 1 AND `keywords` LIKE '%$getme%' ORDER
BY
> > `id` ASC LIMIT 0, 30
> >
> > if $getme = big trees
> >
> > then it would only search for key words that are there same "big trees"
not
> > for " big and trees"
>
>
> Split up your keywords. Loop through each one to construct something like:
>
>  SELECT * FROM `hyperlinks` WHERE 1
>     AND `keywords` LIKE '%big%'
>     AND `keywords` LIKE '%trees%'
>   ORDER BY `id` ASC LIMIT 0, 30
>
>
> This will only match when ALL the specified keywords are present. To match
on
> any one of the keywords construct something like:
>
>
>  SELECT * FROM `hyperlinks`
>   WHERE `keywords` LIKE '%big%'
>      OR `keywords` LIKE '%trees%'
>   ORDER BY `id` ASC LIMIT 0, 30
>
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
>
> /*
> Keep a diary and one day it'll keep you.
> -- Mae West
> */
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to