Mysql Search

From: Philip WATTS (PRWATTS_at_syringa.freeserve.co.uk)
Date: 05/02/04


Date: Sun, 2 May 2004 16:49:20 +0100

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: "call to undefined function" mysql_error when adding new rows to table
    ... I have recently set up a mysql database of local pubs, ... when I try to add a new pub I get an error message "call to undefined ... Shouldn't be any PHP problem. ...
    (comp.lang.php)
  • Re: [PHP] PHP & MySQL Problem
    ... [PHP] PHP & MySQL Problem ... > actually there seems to be no problem with your query (besides that you ...
    (php.general)
  • Re: breaking into J2EE: steep curve or wrong approach?
    ... > a MySQL database. ... > I'd like to recode the PHP functionality as either servlets or JSPs. ... You need to understand servlets. ...
    (comp.lang.java.programmer)
  • Re: Executing PHP files on remote web server
    ... Is it possible to move a few of the PHP pages -- the ... from the session variables on our web server, but I'm a C and Java ... You should have the same security concern for your own MySQL database. ... users with IP addresses on our network, ...
    (comp.lang.php)
  • phpmailer - need help for bulk mailing
    ... I am new to php and mysql. ... I have set up the mailing list in mysql database and used phpmailer to ... The program code is similar to ... Due to the limit of the php program or SMTP server, the browser ...
    (comp.lang.php)