query problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

query problem

Post by itsmani1 »

My query is working fine but i want refine this query, for example some pass a string like: silver's, gold's etc then how it will work? it don't work problem for characters like '," etc

Code: Select all

select product.productid from product where product.product_title like '%".$_GET["srchStr"]."%'
any one can help?
ody3307
Forum Newbie
Posts: 21
Joined: Wed Jul 30, 2008 7:29 am

Re: query problem

Post by ody3307 »

I find it simpler to do this:
$query = "'%";
$query .= $_GET["srchStr"];
$query .= "%'"
(wrap the search string first)
Then...
"select product.productid from product where product.product_title like $query"
(the $query variable includes the single quotes needed)
Post Reply