You can use the SQL keyword "LIKE" for this. Have a look at the MySQL docs
for full info, but the idea is you'd do something like:
$query = "SELECT * FROM table WHERE question LIKE '%". $search_phrase. "%'";
HTH
Jon
-----Original Message-----
From: Wolfgang Schneider [mailto:[EMAIL PROTECTED]]
Sent: 20 August 2001 11:22
To: php-general
Subject: [PHP] php query for mysql table
Hi
I am a newbie to php + mysql and wanted to ask for some help on a
particular item which I can't seem to find "the right key" in the
documentation. I am trying to set up a simple Q&A system with an entry
page where one can select to either have all questions & answers from a
mysql database displayed or else search with a text field for only
those questions which contain a certain word(s).
Can someone tell me how to set in a query when trying to find records
in a mysql table that have a certain word or perhaps 2 or 3 words
(among others) ...?
I know about using SELECT and WHERE in order to find records which
match *exactly*, but am looking for something a bit different ...
Example:
The values of 3 records for the "question" field of the database might
be the following:
[1] How do you deal with anger?
[2] Ever been full of anger in your life?
[3] Is life always easy?
How can I set a PHP query with SELECT and WHERE to express the
following:
Which questions contain the word "life"? That is, have someone search
the database in the "question" field for records where the word "life"
is used as part of the question ... The result then should return the
records 2 & 3 above
Any help is greatly appreciated. Thanks mucho.
God bless you with His grace and peace
Wolfgang
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]