Re: explode () and mySQL query
| From: | Ron Piggott | Date: | Thu, 29 May 2008 00:52:30 +0000 |
| Subject: | Re: explode () and mySQL query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45009@lists.php.net to get a copy of this message | ||
I am not sure why this isn't bringing any results:
WHERE shopping_cart_product.product_description IN ('straying')
The word straying is in the midst of one of the descriptions.
Ron
On Wed, 2008-05-28 at 20:13 -0400, Ron Piggott wrote:
> I am trying to add a search feature to my shopping cart.
>
> I am wanting to use PHP to develop the query for mySQL. I have the
> following code figured out:
>
> foreach(explode(" ", $keyword) as $key) $query .= " $key, ";
>
> This produces:
>
> WHERE shopping_cart_product.product_description IN ( Jesus, is, Lord, )
>
> The weakness is the trailing , after the last word the user types in.
>
> How can I eliminate this?
>
> Ron
--
ron.piggott@actsministries.org
www.actsministrieschristianevangelism.org
Acts Ministries Christian Evangelism
"Where People Matter"
12 Burton Street
Belleville, Ontario, Canada K8P 1E6
In Belleville Phone : (613) 967-0032
In North America Call Toll Free : (866) ACTS-MIN
Fax: (613) 967-9963