Re: Mysql Search
From: Krzysztof Piotrowski (piotrowskikrzysztof_at_gazeta.pl)
Date: 05/02/04
- Next message: JoyRider2005: "Re: Include"
- Previous message: RotterdamStudents: "Include"
- In reply to: Philip WATTS: "Mysql Search"
- Next in thread: Tim Johansson: "Re: Mysql Search"
- Reply: Tim Johansson: "Re: Mysql Search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 2 May 2004 19:30:02 +0200
Philip,
I'm not sure if I understand how your database looks like does - does it
store only single words in designkw column or more than one word per cell?
If you have many words in this field you should try using % ".$searchword."
% (with spaces after and before %). This way you could pick only rows having
whole words, however you will omit words at the beginning and end of the
cell...
If you story only one word per designkw field, you could easily go for
designkw = '" . $searchword . "' - but that's probably not the case
Hope this somehow could help you.
Chris Columbus
"Philip WATTS" <PRWATTS@syringa.freeserve.co.uk> wrote in message
news:c736k2$1fh$1@news7.svr.pol.co.uk...
> I am not sure if this is a PHP or MySql problem, so here goes!
>
> I have a MySql database which has a field containing a list of words
(comma
> seperated). The user inputs a search word to an HTML form which then
> searches this database field for a match, and prints out other fields from
> that datbase record if there is a match.
>
> Currently I have used:-
>
> $query="select * from design where designkw like '%".$searchword."%'";
>
> If the user inputs just a single letter, then this returns every field
that
> has that single letter anywhere in it. I only want an exact match.
>
> Is there a simple way to overcome this?
>
> Currently I am thinking that I must load the field into a PHP variable and
> use strcmp() with this variable and the users input. Would this approach
be
> sensible?
>
>
>
>
- Next message: JoyRider2005: "Re: Include"
- Previous message: RotterdamStudents: "Include"
- In reply to: Philip WATTS: "Mysql Search"
- Next in thread: Tim Johansson: "Re: Mysql Search"
- Reply: Tim Johansson: "Re: Mysql Search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|