文本搜索有两个参数

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.