Re: Mysql Search
From: Tim Johansson (spam_at_gurka.se)
Date: 05/02/04
- Next message: Good Man: "Re: php news/blog"
- Previous message: smurf: "Re: CMS Tutorial"
- In reply to: Krzysztof Piotrowski: "Re: Mysql Search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 2 May 2004 21:27:28 +0200
Try using explode() to put the data into an array, then searching them with
in_array().
-- -- www.gurka.se/gurka.php?x=1&language=english Tremble before the mighty Cucumber "Krzysztof Piotrowski" <piotrowskikrzysztof@gazeta.pl> skrev i meddelandet news:c73b6r$jsf$1@inews.gazeta.pl... > 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: Good Man: "Re: php news/blog"
- Previous message: smurf: "Re: CMS Tutorial"
- In reply to: Krzysztof Piotrowski: "Re: Mysql Search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|