开发者

text search with two parameters

开发者 https://www.devze.com 2022-12-23 07:34 出处:网络
The user should input two strings and the script will performe a开发者_如何学编程 text search:

The user should input two strings and the script will performe a开发者_如何学编程 text search:

$sql = "SELECT * FROM table_one WHERE name='%$str1%' AND MATCH (street, city, pin) AGAINST ('$hrtg'IN BOOLEAN MODE)";

somehow the % does not work, but it alwas did actually. please help?


To use % I think you need LIKE statement


You need to use LIKE:

WHERE name LIKE '%$str1%'

Using = will only find strings that exactly match '%$str1%', including the % signs.


Be careful, your code is vulnerable to SQL injection. You can use prepared statements and bind variables instead. When using MySQL you should at least use mysql_real_escape_string to escape your variables.

0

精彩评论

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