MySql search question. Searching on keywords

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dpg

    MySql search question. Searching on keywords



    How do site searches work?


    I want to create a MySQL database with a field called "keywords". Then a
    form with a search phrase input box.

    I can't figure how to get the results with multiple words using php sql
    query. It's easy with just one word. Do you have to run multiple queries
    based on each word in the query? Then compile each of the results removing
    duplicates.

    Plus..how do you sort results based on matching results.

    Anybody have any tips?








  • dpg

    #2
    Re: MySql search question. Searching on keywords

    Yes, This works good. Thanks Andy


    "Andy Jeffries" <news@andyjeffr ies.remove.co.u k> wrote in message
    news:pan.2003.0 8.07.10.41.22.4 56764@andyjeffr ies.remove.co.u k...[color=blue]
    > On Wed, 06 Aug 2003 00:55:18 +0000, dpg wrote:[color=green]
    > > How do site searches work?
    > >
    > >
    > > I want to create a MySQL database with a field called "keywords". Then[/color][/color]
    a[color=blue][color=green]
    > > form with a search phrase input box.
    > >
    > > I can't figure how to get the results with multiple words using php sql
    > > query. It's easy with just one word. Do you have to run multiple[/color][/color]
    queries[color=blue][color=green]
    > > based on each word in the query? Then compile each of the results[/color][/color]
    removing[color=blue][color=green]
    > > duplicates.[/color]
    >
    > $words = explode(" ", $keywords);
    > foreach ($words as $word) {
    > if (isset($where)) {
    > $where .= " OR ";
    > }
    > $where .= "mysearchfi eld LIKE '%$word%'";
    > }
    >
    >
    > $SQL = "SELECT * FROM mysearchtable WHERE $where";
    >[/color]


    Comment

    Working...