Re: Can anybody help me please???
| From: | Lars Torben Wilson | Date: | Thu, 07 Dec 2000 09:08:30 +0000 |
| Subject: | Re: Can anybody help me please??? | ||
| References: | 1 | Groups: | php.qa |
| Request: | Send a blank email to php-qa+get-1741@lists.php.net to get a copy of this message | ||
> Hello everybody,
> Does any1 know how 2 search for a contain keyword in an MySQL database =
> using PHP.
> For example if i search for ummmm lets say "fo" then it would display =
> everything which has those letters in it like "fo"rd or "fo"cast.
> I already have a piece of the code: $result =3D mysql_query("SELECT * =
> FROM tablename WHERE columnname =3D \"$textboxname\",$db); except for =
> that one little command.
> i've been trying 2 figure it out for months with no luck, if anybody =
> knows how, could u please reply
> Thank You in advanced :-)
>
This is a list for discussion about and amongst PHP's Quality
Assurance team, not for support issues. You want php-general@lists.php.net.
When you post on these lists, though, make sure you turn off HTML
emails in your mailer, or you'll get spanked.
The question isn't even about PHP, though; it's about SQL. You really
should get a book or find a website about SQL--'The Practical SQL
Handbook' by Bowman/Everson/Darnovksy is an excellent starting point.
Anyway, you're looking for "SELECT * FROM tablename WHERE columnname
like '%fo%". i.e. use 'like' instead of '=' and remember that % is
something like DOS's '*'.
Good luck,
Torben
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+