Re: Mysql Search

From: Krzysztof Piotrowski (piotrowskikrzysztof_at_gazeta.pl)
Date: 05/02/04


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?
>
>
>
>



Relevant Pages

  • Re: Mysql Search
    ... Try using explodeto put the data into an array, then searching them with ... > I'm not sure if I understand how your database looks like does - does it ... The user inputs a search word to an HTML form which then ... >> has that single letter anywhere in it. ...
    (alt.php)
  • Re: Getting user input to go to Access Database
    ... >> I need to put the information that the user inputs to the text boxes ... >> them to the corresponding fields in my database. ... > input on the ms access database or you dont know how to input data on ...
    (microsoft.public.dotnet.framework.aspnet)
  • simple question about preforming a search
    ... I have a form that is used for searching my database. ... In the header of the ... form i have a text box where the user inputs the search criteria and then ... Private Sub Command35_Click ...
    (microsoft.public.access.forms)
  • Re: excel form populating in access 2002-03 but not 2007
    ... I dont have the exact error msg, ... I have designed an excel form which is used by multiple users to input ... when user inputs the data in the excel form and clicks submit, ... Here is my code to connect to the database. ...
    (microsoft.public.excel.programming)
  • Re: Error while trying to synchroniza a database on Sql server with a pda database
    ... Tried with single letter table name, ... nothing seems to set up the synchronization partnership between the cdb ... database on the pda and the database on the sql server. ...
    (microsoft.public.pocketpc.activesync)