开发者

php sql where command to check for containg

I get a string vaiable using POST in my php. I want to append this string so that i can use in the sql query to check for containing this string. I want something like this %string%

What i am do开发者_如何学运维ing now this gives me error:

$hotelName = '%'+hotelName_old+'%';


just to be sure: did you change your statement to ... WHERE fieldname LIKE '%value%'??


it should be like this

$hotelName = "%'".$hotelName_old."'%";


try this.

just directly use your variable.

$sql = "select * from `tbl_name` where `field_name` like '%{$find}%'"
$result = mysql_query($sql);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜